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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Asamadi
Helper I
Helper I

DAX 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 measure:

Ratio = SUMX(FILTER(bb,bb[CASH PREPEYMENT]<>BLANK()),1-(bb[CASH PREPEYMENT]-MIN('bb'[CASH PREPEYMENT]))/(MAX('bb'[CASH PREPEYMENT])-MIN('bb'[CASH PREPEYMENT])))

 

this is my file's link:  https://www.dropbox.com/s/h87fn0n0tczqj1c/Question.pbix?dl=0

 

i can solve it in excel like image below:

002.PNG

 

 but i colundt solve it in power bi with dax

 

 

 

 

Capture.PNG

1 ACCEPTED SOLUTION

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 )
    )

Na_N_Error_DAX_calculate_ratio

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Asamadi,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Community Champion
Community Champion

Please 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.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I have updated my recent post

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 )
    )

Na_N_Error_DAX_calculate_ratio

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors