Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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

  • 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

     

4 Replies

  • nvprasad's avatar
    nvprasad
    Icon for Solution Sage rankSolution 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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi nvprasad 

       

      Thank you, this worked

      Much appreciated

       

      Bailey14

       

  • Anonymous's avatar
    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's avatar
      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