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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Calculation previous month by category

Hello, everyone,

 

I need to calculate, on a table that has dates and values, and different categories for this values, where there is only one value for each permutation of dates and categroies, the value of of the previous month for the same categories as the month in question.

 

I have tried the following, which works for the month in question, but if you try to calculate the previous month, it does not work.

Increment / NCS = 
            CALCULATE(
                SUM('Table'[Value]), 
                PARALLELPERIOD('Table'[MonthYear], -0, MONTH)
            )

 This would be the one that does not work:

Increment / NCS = 
            CALCULATE(
                SUM('Table'[Value]), 
                PARALLELPERIOD('Table'[MonthYear], -1, MONTH)
            )

 

So I assumed I could try to filter by categories before applying the calculation, but I don't seem to be doing it correctly. This is what I have tried:

Increment / NCS = 
            CALCULATE(
                SUM('Table'[Value]), 
                PARALLELPERIOD('Table'[MonthYear], -0, MONTH),
                'Table'[Category1] = 'Table'[Category1],
                'Table'[Category2] = 'Table'[Category2],
                'Table'[Category3] = 'Table'[Category3]
            )

 

Thank you very much for your help!

1 ACCEPTED SOLUTION
vivran22
Community Champion
Community Champion

Hello @Anonymous ,

 

You may want to use a different time intelligence function for this. I have created it on a sample data for your reference:

 

Capture.JPG

 

Previous Month = CALCULATE([Value Sum],PREVIOUSMONTH(Sheet1[Month]))

where
Value Sum = SUM(Sheet1[Value])

 

Regards,
Vivek

If it helps, please mark it as a solution

Kudos would be a cherry on the top 🙂

https://www.vivran.in/

View solution in original post

2 REPLIES 2
vivran22
Community Champion
Community Champion

Hello @Anonymous ,

 

You may want to use a different time intelligence function for this. I have created it on a sample data for your reference:

 

Capture.JPG

 

Previous Month = CALCULATE([Value Sum],PREVIOUSMONTH(Sheet1[Month]))

where
Value Sum = SUM(Sheet1[Value])

 

Regards,
Vivek

If it helps, please mark it as a solution

Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Anonymous
Not applicable

Hello , @vivran22 , thanks for your answer, it works like a charm.

 

Can I ask you why does it not work if you don not calculate the sum() in a different measurement?

 

Thanks!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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