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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
HEW
Helper III
Helper III

Calculate % deviation of beginning and end value in Matrix

Hi.

 

I have a matrix, where I show the delelopment in cost prices and I would like to have a column at the end showing the % deviation from the beginning value to the end value. For example, the value for the first row should be 10,59%. I would like it to be dynamic according to the date range selected in the slicer.

 

Matrix dev.png

 

Is this possible? 

The cost price value is based on below measure:

 

PricePerStartOfMonth =
VAR c_article = SELECTEDVALUE ( 'Historic_Gross_price'[Materiale] )
VAR c_date = SELECTEDVALUE ( DimDate[FullDate] )
RETURN
CALCULATE (
MAX ( 'Historic_Gross_price'[Price] ),
'Historic_Gross_price'[Materiale] = c_article,
c_date >= 'Historic_Gross_price'[Date start],
c_date <= 'Historic_Gross_price'[Date end]
)
 
My table has below structure:
Historic_Gross_Price table   
Article no.Date startDate end Price 
101.01.201830.11.2021            12,00
101.12.202131.12.9999            15,00
201.01.201831.12.9999            22,00
301.01.201831.01.2022            25,00
301.02.202231.12.9999            26,00

 

Thanks a lot in advance.

Helen

3 REPLIES 3
amitchandak
Super User
Super User

@HEW , we can change the grand total usng the final measure to show diff in grand total

 

diff =
VAR c_article = SELECTEDVALUE ( 'Historic_Gross_price'[Materiale] )
VAR _min = minx (allselected(DimDate), DimDate[FullDate] )
VAR _max = maxx (allselected(DimDate), DimDate[FullDate] )
RETURN
CALCULATE (
MAX ( 'Historic_Gross_price'[Price] ),
'Historic_Gross_price'[Materiale] = c_article,
_max >= 'Historic_Gross_price'[Date start],
_max <= 'Historic_Gross_price'[Date end]
) -
CALCULATE (
MAX ( 'Historic_Gross_price'[Price] ),
'Historic_Gross_price'[Materiale] = c_article,
_min >= 'Historic_Gross_price'[Date start],
_min <= 'Historic_Gross_price'[Date end]
)


final meausre =
If(isinscope(DimDate[FullDate]), [PricePerStartOfMonth], [diff])

 

 

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

Thanks a lot for taking the time to help. It is really appreciated!

 

I managed to solve the issue with the final measure and it seems to work with below:

 

Dev% =
VAR c_article = SELECTEDVALUE ( 'Historic_Gross_price'[Materiale] )
VAR _min = minx (allselected(DimDate), DimDate[FullDate] )
VAR _max = maxx (allselected(DimDate), DimDate[FullDate] )
RETURN
DIVIDE([Diff],
CALCULATE (
MAX ( 'Historic_Gross_price'[Price] ),
'Historic_Gross_price'[Materiale] = c_article,
_min >= 'Historic_Gross_price'[Date start],
_min <= 'Historic_Gross_price'[Date end]
) )
 
However, I do have a problem if theres no value in the first column. Any suggestion how to adjust the measure to use the first available value in selected period?
Matrix dev %.png
 
Thanks a lot!
Helen

Thanks a lot for your reply.

 

I must be doing something wrong as I get a wrong result:

Matrix dev new.png

 

It seems like theres no begin value...

 

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors