Forum Discussion
Showing Only Total Labels for Stacked Bar Chart with Conditional DAX Logic
- 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!
0Experience Is there a particular reason your relationship is not active? You should be able to solve this with conditional formatting for your Data Label values.
Greg_Deckler thanks Greg. If I make the relationship active then I can not see type-12 in my visual (if I select it from slicer).
- Greg_Deckler1 year ago
Community Champion
0Experience The way you have this configured I don't think it is actually possible. The reason is that you want the label to be visible and invisible under technically the same conditions. I realize that this might not sound correct but create two measures like so:
Measure 1 = COUNTROWS( 'Test_Data_Table' ) Measure 2 = COUNTROWS( 'type_sort' )Use each of those in turn for you data labels and you'll see what I mean.
- 0Experience1 year ago
Helper III
Thanks Greg_Deckler You're probably right, it might not be possible to display this.
I tried your suggested methods. While Measure 2 correctly shows a count of 4 when I select four types from the slicer, the visual still displays only 1 (it make sense too).
I also applied a condition like “if Measure 2 > 2, then hide data labels,” but unfortunately, it didn’t.
Still, I really appreciate your time and thoughtful suggestions.
Thank you!
- FBergamaschi1 year ago
Super User
Hi 0Experience,
(again) 🙂
I might have made it, the file is here, can you check this satisfies your requirements? The only thing that seems to me impossible is to hide the labels if you select multiple items differently than type1 and type-12
https://drive.google.com/drive/folders/14HuWjOKld9A5x-oHacplyMRa6J5rNyjd?usp=sharing
Hope I helped
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI