The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 stacked chart, combination of type-1 and type-2.
If I select multiple selection from slicer then no individual data label will come (will show only total).
I'm currently using a DAX measure in Power BI to hide data labels when selecting type-1 and type-2 (at the same time) from a slicer. But, it is not working. It is showing (individual data labels, and total data labels both)
Data Label =
VAR SelectedCategories = VALUES(type_sort[type]) -- Get all selected categories
VAR ConcatenatedSelection = CONCATENATEX(SelectedCategories, [type], ", ")
RETURN
IF(
ConcatenatedSelection = "type-1, type-2",
"", -- Hide the data label
[describeMeasure] -- Otherwise, show the data label
)
As I mentioned before, I need to turn on total labels on to see the total for the type-12 (when selecting it only). I also need to turned on the data labels to see data point when selecting a single selection of type-1/type-2/type-3.
If anyone has suggestions for improving the DAX or alternative approaches to achieve this behavior, I’d really appreciate it.
You can find the Power BI file here: [link]
Solved! Go to Solution.
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!
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).
@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.
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!
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
@FBergamaschiThank you so much for your time, your help, and the code you shared, I truly appreciate it.
It was good to see that the code worked partially. However, when I applied it to my actual dashboard, it unfortunately didn’t behave as expected (even for Type-12 and type-1) too. The data labels are still showing for every combination.
Still, I’m really grateful for your support and suggestions.
Thanks again!
User | Count |
---|---|
10 | |
9 | |
6 | |
6 | |
5 |
User | Count |
---|---|
20 | |
15 | |
14 | |
10 | |
7 |