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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dashbuilder
New Member

Measure is calculated incorrectly in a table

Hi all,

I would appreciate it if someone could help me please with my measures:

I have the following table:

DateItemPrice
01.01.2020A20
01.01.2020A25
01.01.2020A30
03.01.2020A20
10.01.2020A35
02.01.2020B50
05.01.2020B60
01.01.2020C40
01.01.2020C45
01.01.2020C50
03.01.2020C40
10.01.2020C45


I have calculated the percentage change for each item taking the average price for the day based on the date slicer as follows:

 

 

 

Percent Change =
var _max = maxx(Table,Table[Date].[Date])
var _min = MINX(Table,Table[Date].[Date])
return
(CALCULATE(AVERAGE(Table[Price]), FILTER(ALLSELECTED(Table),Table[Date].[Date]=_max))-CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED(Table),Table[Date].[Date]=_min)))/CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED(Price),Table[Date].[Date]=_min))*100

 

 

 

 

 When I select individual items, the percentage is calculated correctly between min and max dates as follows:

Capture.JPG

But when I select all items, I get different percentage changes

Capture1.JPG

Can anyone please help me to get the correct percentage changes when I select all items (the same values as when I select just one item)? I would like to present changes for all items in a table.

 

Thanks

1 ACCEPTED SOLUTION

@dashbuilder , I created three versions of it, Please check those out in the file attached after signature

 

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

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@dashbuilder , Create a separate date table and then try same formula with date table 

example - 

Percent Change =
var _max = maxx('DATE','DATE'[Date])
var _min = MINX('DATE','DATE'[Date])
return
(CALCULATE(AVERAGE(Table[Price]), FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_max))
-CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_min)))/
CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_min))*100

 

Also, use the divide function 

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 thank you for your response. I have created a new data table as followsCapture2.JPG

Then, I altered the formula as suggested:

Percent Growth = 
var _max = maxx('DATE','DATE'[Date])
var _min = MINX('DATE','DATE'[Date])
return
DIVIDE((CALCULATE(AVERAGE(Table[Price]), FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_max))
-CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_min))),
CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_min)))*100

Now, I get "0"s:

Capture4.JPG

Am I doing something wrong? Thank you heaps.

@dashbuilder , I created three versions of it, Please check those out in the file attached after signature

 

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

Awesome, thank you heaps @amitchandak

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.