Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Create a measure for relative error with values in same column, for different categories

 

Hello, I need help with a measure for a Relative Error 

%Prediction could be created with method A or B and there's a Base Method. So, for month 1,2, and son on, i need relative error between method A and Base (PRediction with method A  - Prediction with Base method) / Prediction with Base method. 

For january and method A:  (20%-22%)/22%  = -9,1% 

For method B, same thing:   (Prediction with method B  - Prediction with base method) / Prediction with base method

so for january and method B: (21%-22%)/22% = -4,5%

 

Relative error for base method shoud be Zero or Null, it would be plotted later.

 

How can i create this with DAX? i imagine i must create some sort of index. Any guide to achieve this? Many thanks in advance as usually 

 

 

Date / MonthMethod% Prediction%Relative Error (desire result)
01-01-2022A20%-9,1%
01-02-2022A23%-4,2%
01-03-2022A26%-3,7%
01-01-2022B21%-4,5%
01-02-2022B22%-8,3%
01-03-2022B28%3,7%
01-01-2022Base22%                             -
01-02-2022Base24%                             -
01-03-2022Base27%                             -

3 Replies

  • v-xiaotang's avatar
    v-xiaotang
    Icon for Community Support rankCommunity Support

    Hi Anonymous 

    Thanks for reaching out to us.

    try this measure

    Relative Error = 
     var _base= MAXX(FILTER(ALL('Table'),'Table'[Date / Month]=MIN('Table'[Date / Month]) && 'Table'[Method]="Base"),[% Prediction])
     return ([% Prediction]-_base)/_base

     

    Best Regards,

    Community Support Team _Tang

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi! sorry to ask again, it worked, i was just wondering if you can explain what the formula is doing?. I'm not understanding logic behind DAX and i'd like to improve my reports by understanding it better. 

      What does MAXX and MIN like in few words, i get that you filtered BASE but i dont get that MAXX and min part.

      Thank you

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you a lot!!! it worked! ðŸ¤—