Forum Discussion

0Experience's avatar
0Experience
Helper III
1 year ago
Solved

Showing Only Total Labels for Stacked Bar Chart with Conditional DAX Logic

Hello,   If I select single selection from slicer (type-1/type-2/type-3) then need to see the data value like below.      If I select single selection from slicer (type-12 only) which is a...
  • 0Experience's avatar
    1 year ago

    The code works fine when I kept both Data Labels and Total Labels turned on.

     

    Data_Label = 
    VAR SelectedTypes = ALLSELECTED(type_sort[type])
    VAR SelectedCount = COUNTROWS(SelectedTypes)
    
    RETURN
    IF(
        SelectedCount = 1 &&
        MAX(type_sort[type]) IN { "type-1", "type-2", "type-3" },
        [describeMeasure],
        BLANK()
    )

     

    If I select only type-1

     

    If I select combination of type-1/type-2/type-3

     

    If I select only type-12

     

    If I select any combination of type-1/type-2/type-3/type-12

     

     

    Note: While ChatGPT provided the final working code, I had already shared the initial code, expected output, and other relevant details. It took a few iterations to get everything functioning correctly.

     

    Thanks to everyone who engaged with my post and offered helpful suggestions, your input was truly appreciated!