Forum Discussion
Asamadi
Helper I
8 years agoDAX calculate ratio
I want to calculate ratio ( for normalization) and i get error NaN how can i solve it? it must be divide (CASH PAYMENT - Min(CASH PAYMENT), Max(CASH PAYMENT) - Min(CASH PAYMENT)) this is my measur...
- 8 years ago
Hi Asamadi,
Try the measure below.
Measure = VAR minCP = CALCULATE ( MIN ( bb[CASH PREPEYMENT] ), ALL ( bb ) ) VAR maxCP = CALCULATE ( MAX ( bb[CASH PREPEYMENT] ), ALL ( bb ) ) RETURN IF ( ISBLANK ( MIN ( bb[CASH PREPEYMENT] ) ), BLANK (), 1 - DIVIDE ( MIN ( bb[CASH PREPEYMENT] ) - minCP, maxCP - minCP ) )Best Regards,
Dale
Greg_Deckler
Community Champion
8 years agoPlease see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
That being said, split your numerator and denominator into VAR statements and then use RETURN to display one or the other and see where the problem is. You can use DIVIDE with the 3rd parameter to get around errors but I'm assuming you are expecting a ratio and not getting one. Otherwise, provide some sample data and can try to replicate.
Asamadi
Helper I
8 years agoI have updated my recent post
- v-jiascu-msft8 years ago
Microsoft Employee
Hi Asamadi,
Try the measure below.
Measure = VAR minCP = CALCULATE ( MIN ( bb[CASH PREPEYMENT] ), ALL ( bb ) ) VAR maxCP = CALCULATE ( MAX ( bb[CASH PREPEYMENT] ), ALL ( bb ) ) RETURN IF ( ISBLANK ( MIN ( bb[CASH PREPEYMENT] ) ), BLANK (), 1 - DIVIDE ( MIN ( bb[CASH PREPEYMENT] ) - minCP, maxCP - minCP ) )Best Regards,
Dale