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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Maahmohammed
Helper I
Helper I

How to use if function in the mathematical calculations?

I have 2 columns, one is the product_id & the other is the GM%,

I need to create the below calculated column or a measure with the below formaula:

If(GM%<10,"0",
IF(GM%<20,"Divide(GM%,2)",
"10"
))

But the output of (if) is text, i couldn't make a calculation.

How could you help me?

Regards

Maahmohammed_0-1726768093916.png

 

1 ACCEPTED SOLUTION
dharmendars007
Super User
Super User

Hello @Maahmohammed , 

 

Please try the below measure I have used Switch instead of "IF" which is more readable.

 

AdjustedGMMeasure =
SWITCH(TRUE(),
SUM(Table[GM]) < 10, 0,
SUM(Table[GM]) < 20, DIVIDE(SUM(Table[GM]), 2),10)

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Maahmohammed 

 

Make sure that the data format of the "GM%" column is a numeric type.

vxianjtanmsft_1-1726814572497.png

In my simple test, the measure works.

Also, the SWITCH function suggested in dharmendars007's reply is a valid solution.

 

AdjustedGM% = IF(SELECTEDVALUE('Table'[GM%]) < 10, 0, IF(SELECTEDVALUE('Table'[GM%]) < 20, DIVIDE(SELECTEDVALUE('Table'[GM%]), 2), 10))

 

vxianjtanmsft_0-1726814262204.png

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Maahmohammed 

 

Just a friendly follow up on the case, may I know if these replies have helped you resolve the issue? If they have, please consider accepting helpful reply as a solution.

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

dharmendars007
Super User
Super User

Hello @Maahmohammed , 

 

Please try the below measure I have used Switch instead of "IF" which is more readable.

 

AdjustedGMMeasure =
SWITCH(TRUE(),
SUM(Table[GM]) < 10, 0,
SUM(Table[GM]) < 20, DIVIDE(SUM(Table[GM]), 2),10)

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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