Forum Discussion

JustinDoh1's avatar
JustinDoh1
Post Prodigy
5 years ago

Total comes out as zero (while using Switch statement)

I am sharing my Pbix file here.   

I am fairly new to DAX, and I tried SWITCH statement for the first time today.

Somehow, when there is any occurrence of outcome of 0, Total comes out to be 0.

So, on this case because Jane Doe has output of 0, total is 0.

But, somehow, it does not sum up as expected to 1.

 

I have only two examples here, but total should be 1 in this case.

 

I think there is something I need to fix on the DAX code, but I am not sure where/why.

This measure is called "Refused 0818" in the file.

 

The logic here is, when there is 1st case, output is 1, second case --> 0, third case --> 0, otherwise vRefused

Isn't it?

 

 

Thank you for any feedback.

 

3 Replies

  • JustinDoh1 , when you use rows context example min/max (min(A) = "A")  in a measure. the calculations are done at row level. And unless we use allselected and all, we are still on the same visual row.

     

    In such a case, the grand total is recalculated. It misses the context as it does not have a name. That we why we take the help of summarize or values to group data from rows level to grand total level

     

    As, summarize do not work same as the visual table always, we need to work on our formula

     

    is this different from

    https://community.powerbi.com/t5/DAX-Commands-and-Tips/Trying-to-understand-the-outcome-from-my-DAX-code-using-Min-amp/m-p/2024118#M45185

     

     

     

     

    • JustinDoh1's avatar
      JustinDoh1
      Post Prodigy

      amitchandak 

      Thank you for your feedback.

      I was using SWITCH, but my output is still very unstable. How do I go about wrapping up my calculate to be obvious and stable?
      How do I go about "summarize or values to group data from rows level to grand total level"? 

      Do I go that in the Calculate function at VAR section or inside Switch area?

      Thanks.

       

      I have updated file here.

       

  • @amitchandak I would like to follow up on my inquiries. I am anxious to know how to fix row context issue in this case. Thank you so much!