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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

write a measure to switch the calculation

Hello Folks

 

I have a simple measure to calculate the percentage accuracy of the cost of stock counted

% value accuracy=

DIVIDE(

SUM(actualcost)

SUM(system cost)

in some cases the % comes back as over 100%. How do I write the measure so that it switches the calculation in those cases?

 

Thanks

 

Bailey14

1 ACCEPTED SOLUTION
nvprasad
Solution Sage
Solution Sage

Hi,

You can write like below

 

% value accuracy=

if(

DIVIDE(

SUM(actualcost)

SUM(system cost),0) >1 then 

DIVIDE(

SUM(system cost),SUM(actualcost),0) , 

DIVIDE(

SUM(actualcost)

SUM(system cost),0))

 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

What is the correct result? How to deal with it when the returned value of measure "% value accuracy" is over 100%? Could you please explain it with examples? Please check if the below formula is what you want:

% value accuracy =
VAR _per =
    DIVIDE ( SUM ( [actualcost] ), SUM ( [system cost] ) )
RETURN
    IF ( _per > 1, 1, _per )

Best Regards

Rena

Anonymous
Not applicable

Hi @Anonymous 

 

Yes, I'm looking for the measure to deal with the result by switching the formula around if the result is over 100%, as I'm new to writing measures I don't know how to express it in the dax. 

I tried your solution but VAR _per couldn't be found? There was another solution which worked so the problem has been solved.

Thank you for your time

 

Regards

Bailey14

nvprasad
Solution Sage
Solution Sage

Hi,

You can write like below

 

% value accuracy=

if(

DIVIDE(

SUM(actualcost)

SUM(system cost),0) >1 then 

DIVIDE(

SUM(system cost),SUM(actualcost),0) , 

DIVIDE(

SUM(actualcost)

SUM(system cost),0))

 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.
Anonymous
Not applicable

Hi @nvprasad 

 

Thank you, this worked

Much appreciated

 

Bailey14

 

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.