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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DannyPhan
New Member

Wrong total for sub categories

I'm new to Power BI, can anyone help me fix this Measure: 

Test =
var prev_index = MAX(version_code[index])-1
var prev_ver = LOOKUPVALUE(version_code[ver], version_code[index], prev_index, "")
RETURN
CALCULATE(SUM('Version'[NC_TT_TN]), FILTER(ALLEXCEPT('Version', 'Version'[MTC]), 'Version'[Ver] = prev_ver))

 

DannyPhan_1-1729159054311.png

DannyPhan_2-1729159087286.png

BF =Before, AF = After. I want to take the results from column BF and this display them in the column AF in order to calculate the variance.

3 REPLIES 3
v-zhouwen-msft
Community Support
Community Support

Hi @DannyPhan ,

Can you provide .pbix files without sensitive data or simply data?

If you are unsure how to upload data please refer to

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,
Wenbin Zhou

 

rajendraongole1
Super User
Super User

Hi @DannyPhan - I suggest making adjustments to the prev_index logic and filtering to ensure it looks for the previous row based on your custom index logic. Please use the updated measure 

 

Test =
VAR current_index = MAX(version_code[index])
VAR prev_index = current_index - 1
VAR prev_ver = LOOKUPVALUE(version_code[ver], version_code[index], prev_index)
RETURN
CALCULATE(
SUM('Version'[NC_TT_TN]),
FILTER(
ALLEXCEPT('Version', 'Version'[MTC]),
'Version'[Ver] = prev_ver
)
)

 

Hope this works to display the expected output.





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

Proud to be a Super User!





Thanks for your answer @rajendraongole1 . But it still display the same result as before. Noted that the model has parent child hierachy.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.