0
votes

I am trying to find the cumulative total to show in line chart in Power BI.My data does not have date column but I have week Id and week number column and I have one flag column.My sales_datatable looks like below:

enter image description here

I want to get the cumulative total like below so that I can show in the line chart I want to include one condition : only the last 52 week flag = 1

enter image description here

All the solution I have found online required date column.But in my case there is no date. please help

1

1 Answers

1
votes

Try this below custom column code-

cumulative_sum = 

VAR current_row_week = table_name[week]

RETURN
CALCULATE(
    SUM(table_name[sales]),
    FILTER(
        ALL(table_name),
        table_name[week] <= current_row_week 
        && table_name[last 52 week flag] = 1  
    )
)