Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
this is my table
i want to calculate ratio based on ID and Sub ID in a measure. in power bi
Like this:
Solved! Go to Solution.
Hi @MrDarian ,
Try this measure
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
I have improved the DAX beause I am not if the max of subid is always 4 for each ID.
The previous DAX has some problem .
Please try the below measure
RATIO =
VAR ID2=if('Sheet4 (2)'[ID]=min('Sheet4 (2)'[ID])&&'Sheet4 (2)'[SUBID]=1,'Sheet4 (2)'[ID],if('Sheet4 (2)'[SUBID]=1,'Sheet4 (2)'[ID]-1,'Sheet4 (2)'[ID]))
VAR SUBID2=IF('Sheet4 (2)'[ID]=MIN('Sheet4 (2)'[ID])&&'Sheet4 (2)'[SUBID]=1,1,IF('Sheet4 (2)'[SUBID]=1,MAXX(FILTER('Sheet4 (2)','Sheet4 (2)'[ID]=ID2),'Sheet4 (2)'[SUBID]),'Sheet4 (2)'[SUBID]-1))
VAR newamount= MAXX(FILTER('Sheet4 (2)','Sheet4 (2)'[ID]=ID2&&'Sheet4 (2)'[SUBID]=SUBID2),'Sheet4 (2)'[Amount])
RETURN 'Sheet4 (2)'[Amount]/newamount
hope this is helpful
Proud to be a Super User!
YOUR RESPONES WORKED. BUT I NEED MEASURE INSTEAD OF CALCULATED COLUMN
Hi @MrDarian ,
Create a Calculated Column
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
please try below measure to create a column
ratio =
VAR subamount=MAXX(FILTER(Sheet4,Sheet4[ID]=EARLIER(Sheet4[ID])&&Sheet4[SUBID]=EARLIER(Sheet4[SUBID])-1),Sheet4[Amount])
VAR subamount2=MAXX(FILTER(Sheet4,Sheet4[ID]=EARLIER(Sheet4[ID])-1&&Sheet4[SUBID]=max(Sheet4[SUBID])),Sheet4[Amount])
VAR minID=MIN(Sheet4[ID])
return if(Sheet4[ID]=minID,if(Sheet4[SUBID]=1,Sheet4[Amount]/Sheet4[Amount],Sheet4[Amount]/subamount),if(Sheet4[SUBID]<>1,Sheet4[Amount]/subamount,Sheet4[Amount]/subamount2))
Proud to be a Super User!
thank you. is it possible to do by measure not calculated column?
Hi @MrDarian ,
Try this measure
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
thanks for your response, measure also worked. is it possible to explain how to do?
this is your measure.
@MrDarian , if this not excel, what is logic to divide, odd even sub id?
ID is changed and sub ID start from 1 to 4
i need a dax code to divide rows based on the previous row ( the logic previous sub ID and when ID is changed sub ID starts from 1. )
then both of them are necessary.
Hi @MrDarian ,
It seems that you always use the current column value divide by the previous column value no matter the ID and SUB ID, right?
Aiolos Zhao
ID and sub ID are important because ID is changed and sub ID start from 1 to 4
i need a dax code to divide rows.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
121 | |
79 | |
47 | |
45 | |
36 |
User | Count |
---|---|
179 | |
89 | |
69 | |
47 | |
47 |