Forum Discussion
MrDarian
6 years agoHelper II
Calculate Ratio
this is my table i want to calculate ratio based on ID and Sub ID in a measure. in power bi Like this:
- Anonymous6 years ago
Hi MrDarian ,
Try this measure
RatioMeasure =var _minsub = CALCULATE(MIN('Table22'[Sub ID ]), FILTER(ALL('Table22'),'Table22'[ID] = MAX('Table22'[ID])))var _maxsubid = CALCULATE(MIN('Table22'[Amount]),FILTER(ALL('Table22'),'Table22'[ID] = MAX('Table22'[ID])-1 && 'Table22'[Sub ID ] = MAXX(ALL('Table22'),Table22[Sub ID ])))var _previousamount = CALCULATE(MAX('Table22'[Amount]), FILTER(ALL('Table22'),'Table22'[ID] = MAX('Table22'[ID]) && 'Table22'[Sub ID ] = MAX( 'Table22'[Sub ID ]) -1))RETURNSWITCH(TRUE(),MAX('Table22'[Sub ID ]) = _minsub && MAX('Table22'[ID]) = MINX(ALL('Table22'[ID]),Table22[ID]), DIVIDE(MAX('Table22'[Amount]),MAX('Table22'[Amount])),MAX('Table22'[Sub ID ]) = _minsub, DIVIDE(MAX('Table22'[Amount]),_maxsubid),DIVIDE(MAX('Table22'[Amount]),_previousamount))Regards,
Harsh NathaniDid I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
amitchandak
6 years agoSuper User
MrDarian , if this not excel, what is logic to divide, odd even sub id?
- MrDarian6 years agoHelper II
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.