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
Simone2004
Helper I
Helper I

How to calculate differences between rows in a matrix with custom aggregations

Hi everyone,

I have this matrix

Simone2004_0-1620772150424.png

As you can see, the rows are aggregated by months, quarters and years. The values in the matrix are about sales.

 

Now I need to calculate the difference between the sales in a month and its previous one. The same must be done for quarters and years.

 

I do some examples. I need to calculate the difference between

- Year 2021 and Year 2020

- Quarter2 2020 and Quarter1 2020

- Quarter4 2020 and Quarter1 2019

- February 2021 and Jenuary 2021

- Jenuary 2021 and December 2020

 

To make things more complicated 😞 User can filters data. So for example, he could decide to visualize in the matrix data just for 2015 and 2018, then excluding 2016 and 2017. In that case, I should consider 2014 as the previous row of 2018 and not 2017.

Simone2004_1-1620772963585.png

Then, in this situation 

I need to calculate the difference between

- Year 2018 and Year 2015

- Quarter2 2018 and Quarter1 2018

- Quarter4 2015 and Quarter1 2018

- February 2018 and Jenuary 2018

- Jenuary 2018 and December 2015

 

 

Any help is appreciated. 

Thnak you

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @Simone2004,

Any update on your requirement?
You can also take a look at the following link to know how to use if statement checks current hierarchy level then you can write a formula with filter for these parameters range calculation.

Clever Hierarchy Handling in DAX - SQLBI

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
v-shex-msft
Community Support
Community Support

HI @Simone2004,

Current power bi visual aggerate feature does not support these, you need to manually write measure formula with filter condition to calculate and compare with specific range records.

If you confused about the coding formula, please share some dummy data to test.

How to Get Your Question Answered Quickly
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@Simone2004 , as of now, power bi does not support row operations, which means the difference has come from measures.

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.