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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors