Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Help with Switch case

Hi,

I have to add custom column called "score".For that i have to add switch case as below: 

 

CASE

WHEN isnull(N_SUM_of_Absolute_us...) THEN 

WHEN (N_SUM_of_Absolute_us... NOT NULL) and isnull(Y_SUM_of_Absolute_us...) THEN 1

ELSE round(N_SUM_of_Absolute_us.../(N_SUM_of_Absolute_us... + Y_SUM_of_Absolute_us...), 4)

 END

 

Can someone help me how to do this.

Thanks.

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous 

    Thank you so much.It worked.

4 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion

    Hi, Anonymous , you may apply such a pattern to your measure,

     

    Measure = 
    SWITCH( TRUE(),
    ISNULL(N_SUM_of_Absolute_us...), 0,
    ISNULL(Y_SUM_of_Absolute_us...), 1,
    round(N_SUM_of_Absolute_us.../(N_SUM_of_Absolute_us... + Y_SUM_of_Absolute_us...), 4)
    )

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi CNENFRNL ,

      When am trying to apply that it is showing the below error.

      Note : Even i changed the table name.still it showing the same error.

      Thanks.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous 
    There is no isnull function in DAX  and N_SUM_of_Absolute_us... and Y_SUM_of_Absolute_us... are columns so, need an aggregate function. Try create the measure with ISBLANK():

     

    Measure = SWITCH( TRUE(),
    ISBLANK(max([N_SUM_of_Absolute_us...])), 0,
    ISBLANK(max([Y_SUM_of_Absolute_us...])), 1,
    round(MAX([N_SUM_of_Absolute_us...])/(max([N_SUM_of_Absolute_us...]) + max([Y_SUM_of_Absolute_us...])),4)
    )

     

    Paul Zheng _ Community Support Team
    If this post helps, please Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous 

      Thank you so much.It worked.