cancel
Showing results for
Did you mean:
Helper I

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

Hi everyone,

I have this matrix

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.

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
Community Support

HI @Simone2004,

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.
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.

Xiaoxin Sheng

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

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

Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

Announcements

#### Launching new user group features

Learn how to create your own user groups today!