Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Average If condition

Hi All,

 

What can I use instaead to  MAX in the below measure to calculate Average based on some conditions:

 

Measure = IF(MAX(View_DealClosing[Unit] = "DTH"),
CALCULATE(AVERAGE(View_DealClosing[PrimaryAdder])*0.1),
CALCULATE(AVERAGE(View_DealClosing[PrimaryAdder])))
 

 

Regards,

Himanshu

  • Hi there!

    MAX is returning an error because you are closing the braket after the condition, you should close the MAX braket right after the column. It would look like this:

    Measure = IF(MAX(View_DealClosing[Unit]) = "DTH",
    CALCULATE(AVERAGE(View_DealClosing[PrimaryAdder])*0.1),
    CALCULATE(AVERAGE(View_DealClosing[PrimaryAdder])))
    Let me know if that solves your problem!

2 Replies

  • nvprasad's avatar
    nvprasad
    Solution Sage

    Hi 

     

    Your Question & Dax is not clear. However my assumption is if user selects DTH then you want to multiply with 0.1 else you want to take average.

    Dax = IF ( SELECTEDVALUE(View_Dealclosing[Unit]) = "DTH",

                       AVERAGE(View_Dealclosing[PrimaryAdder])*0.1,

                       AVERAGE(View_Dealclosing[PrimaryAdder]))

     

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

    Regards,
    N V Durga Prasad

  • Hi there!

    MAX is returning an error because you are closing the braket after the condition, you should close the MAX braket right after the column. It would look like this:

    Measure = IF(MAX(View_DealClosing[Unit]) = "DTH",
    CALCULATE(AVERAGE(View_DealClosing[PrimaryAdder])*0.1),
    CALCULATE(AVERAGE(View_DealClosing[PrimaryAdder])))
    Let me know if that solves your problem!