Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mk94
Frequent Visitor

Reset cumulative sum when new sales period starts

Hi everyone

 

I need help with a cumulative measure. I have a measure (Sum_Prod) that sums the sales of some product. Every row of my data table contains the sales numbers for every calendar week for the years 2020 - 2023. This is the DAX for the measure Sum_Prod:

 

 

Sum_Prod = 
CALCULATE(
    SUM(Prod_Table[Prod_Count])
)

 

 

I now need the cumulative sums of that measure for three sales periods:
- Sales Period 20/21 ranging from calendar week 36 2020 to calendar week 35 2021
- Sales Period 21/22 ranging from calendar week 36 2021 to calendar week 35 2022
- Sales Period 22/23 ranging from calendar week 36 2022 to calendar week 35 2023
I later on need to display this measure in a table that I want to filter by sales person so that I get the individual sales performance of filtered sales person. I created the measure like this:

 

 

Cum_Sum_Prod_SalesPeriod = 
VAR CurWeek = MAX(Date_Table[TotalWeeks])
RETURN
CALCULATE([Sum_Prod],
    FILTER(ALL(Date_Table),
            Date_Table[TotalWeeks] <= CurWeek
             && (
                (Date_Table[Year] = 2020 && Date_Table[Calendar_Week] >= 36)
                || (Date_Table[Year] = 2021 && Date_Table[Calendar_Week] <= 35)
                || (Date_Table[Year] = 2021 && Date_Table[Calendar_Week] >= 36)
                || (Date_Table[Year] = 2022 && Date_Table[Calendar_Week] <= 35)
                || (Date_Table[Year] = 2022 && Date_Table[Calendar_Week] >= 36)
                || (Date_Table[Year] = 2023 && Date_Table[Calendar_Week] <= 35)
            )
    )
) + 0

 

 

Everything seems to be correct except that the cumulative sums don't get reseted when a new sales period starts, the measure just counts on. Here some example data for better understanding:

mk94_0-1688143319434.png

Any help or tip what could be the cause of the problem is highly appreciated.

 

Thanks!

1 REPLY 1
lucadelicio
Super User
Super User

Try to create a calculated column on the data table.
In this column you will put the new sales period.
NEW SALES PERIOD =
IF(Date_Table[Calendar_Week] <= 35, YEAR -1, YEAR)
In this way you can put the NEW SALES PERIOD in your table and you obtain what you want.

Automatically you will select the sales period of the new calculated column.

I hope i help you.

It's more easier to help you if you upload your pbix.

Mark as a solution if resolve your problem.

Ciao!

Luca D'Elicio

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.