Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX FORMAT value based on slicer selection

Hi -   I have created three measures: Net Sales per Pound, Volume, and Mix. I want to show each of these measures in a matrix, but only show one measure at a time based on which one is selected in ...
  • v-yalanwu-msft's avatar
    4 years ago

    Hi, Anonymous ;

    Maybe you can optimize the code a little bit as follows, but  I've tested your code and it works. Maybe your data itself or all three measures check to see if they can all return numeric values. You can follow my simple example:

    MeasureSelection = 
    SWITCH(VALUES('Measures Table'[Measure]), 
     "Net Sales/Lb", FORMAT('Sales & Volume Data'[NS per Lb.],"$0.00;($0.00);0 "), 
     "Volume", FORMAT('Sales & Volume Data'[Volume],"0.00;(0.00);0"), 
     "Mix", FORMAT('Sales & Volume Data'[Percent], "0.00%;(0.00%);0"), 
    BLANK())

    The final output is shown below:

    There is another possibility that three measures are applied to the matrix, which shows blank space due to row level reasons. Could you check it? If it is not solved, can you share simple files or screenshots to remove sensitive information?

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.