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
AtomFiske
New Member

Matrix + percentage difference issue

I have monthly recurring tasks and I would like to calculate and visualize these figures. the base data is quite simple (see below), but I can't seem to get this right. I want to calculate the percentage difference between tasks and I would like power bi to show me the percentage difference between two months based on the filtered months that I select.

for example, I want to compare the month 202110 with the month 202210 and see the percentage difference of tasks. And when I change the filter values, I want to compare the months 202209 and 202210 in the same way.

 

i have huge problems with this. Can anyone help me? 

 

 

YYYYMMTaskValue
202110task 1380
202110task 2550
202110task 3120
202209task 1350
202209task 2520
202209task 3150
202210task 1400
202210task 2500
202210task 3100
1 ACCEPTED SOLUTION

Hi @AtomFiske ,

 

In this case you just need to change the second argument of the division use the following metric:

Variation = 
DIVIDE (
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MAX ( 'Table'[YYYYMM] ) )
        - CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) )
)

MFelix_0-1668202369301.png

 

If you want to present the values based on the YYYYMM also then you need to make some changes, this can be an option:

Variation = 
IF(ISINSCOPE('Table'[YYYYMM]), SUM('Table'[Value]),
FORMAT(DIVIDE (
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MAX ( 'Table'[YYYYMM] ) )
        - CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) )
), "#.00%"))

MFelix_1-1668202515359.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
AtomFiske
New Member

Hi! Thank you @MFelix ! This is pretty close, but not quite what I was trying to describe. I probably didn't describe my problem well enough. I will try again with a picture.

pbi issue.jpg

I want to compare the task-specific percentage difference (see the red numbers on the picture) of the two months I selected with the filter, but I don't understand how to make this work. 

 

Hi @AtomFiske ,

 

In this case you just need to change the second argument of the division use the following metric:

Variation = 
DIVIDE (
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MAX ( 'Table'[YYYYMM] ) )
        - CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) )
)

MFelix_0-1668202369301.png

 

If you want to present the values based on the YYYYMM also then you need to make some changes, this can be an option:

Variation = 
IF(ISINSCOPE('Table'[YYYYMM]), SUM('Table'[Value]),
FORMAT(DIVIDE (
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MAX ( 'Table'[YYYYMM] ) )
        - CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) )
), "#.00%"))

MFelix_1-1668202515359.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



this solved my problem. I am extremely grateful for your help @MFelix 

MFelix
Super User
Super User

Hi @AtomFiske ,

 

Try the following code:

Variation = 
DIVIDE (
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MAX ( 'Table'[YYYYMM] ) )
        - CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MIN ( 'Table'[YYYYMM] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[YYYYMM] = MAX ( 'Table'[YYYYMM] ) )
)

Be aware that this code only works if you do not have the yyyymm on your table, if you need to have it this needs to be revised.

MFelix_0-1668159757071.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.