Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
naledi_h
Helper I
Helper I

Show error when item/ option is hidden

I am working with survey data. It's a lot more complex, but here is a sample structure to explain.

naledi_h_0-1668538160852.png
If I show a bar chart by gender, it would have 2 male and 8 female. I want to hide any response that has fewer than 5 respondents though. So I would show only the female bar and hide the male bar. I have a calculation to do this. 

Now I want to show the user a message, which explains that one of the options is not being shown because there are fewer than 5 respondents, so that they don't get confused and think there were no males at all or wonder where that bar has gone. I am struggling with calculating the number of respondents on the response level, when the response itself isn't shown. My expertise is in Tableau (where I would use an INCLUDE LoD) rather than PowerBI and I am struggling to translate my knowledge. 

The two approaches I was considering 
+ Compare the distint count of responses against the total in the data set and show the warning as soon as it is less than the total- I can get the total, but as the filtering works on the response level I don't know how to apply it in a measure to get the current distinct count of responses 
+ Calculate the individual response numbers for each response (e.g. 2 and 8 ) and then flag this as soon as the smallest value is below 5 - same issue, I don't know how to get the number of respondents per response and then get the smallest number from this 

Any hints into the right direction will be useful

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @naledi_h ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create  a table.

Table2 = FILTER(SUMMARIZE('Table','Table'[Response],"Count_Type",COUNT('Table'[ID])),[Count_Type]>=5)

(3)We can create  a measure.

Warning = 
var _discount1=CALCULATE(DISTINCTCOUNT('Table'[Response]))
var _discount2=CALCULATE(DISTINCTCOUNT('Table2'[Response]))
return
IF(_discount2<_discount1,"Warning",_discount2)

(3) Then the result is as follows.

vtangjiemsft_0-1668591655386.png

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
naledi_h
Helper I
Helper I

I think I managed to get the temporary table solution to work. I will still need to do some testing but for now it looks good. Thanks so much. 

naledi_h_1-1668625965442.png

 

naledi_h_0-1668625936119.png

 

naledi_h
Helper I
Helper I

Thank you for taking the time to respond and build out the solution Neeko. 

 

I should have mentioned that I need these results to be filtered dynamically with a set of slicers. I am not quite sure how to connect this new table to my existing table structure and also if the slicer would act at the right stage of the processing (from what I understand slicer actions don't affect calculations in tables as they are processed at an earlier stage?).

 

This is the data structure that I am working with. 

2022-11-16_11-15-05.jpg


It feels like your approach of creating a table and then extracting a value from that is the correct one, but the table might need to be created more temporarily/dynamically/in a measure? I will do some research down that route but of course grateful for any further advice. 

v-tangjie-msft
Community Support
Community Support

Hi @naledi_h ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create  a table.

Table2 = FILTER(SUMMARIZE('Table','Table'[Response],"Count_Type",COUNT('Table'[ID])),[Count_Type]>=5)

(3)We can create  a measure.

Warning = 
var _discount1=CALCULATE(DISTINCTCOUNT('Table'[Response]))
var _discount2=CALCULATE(DISTINCTCOUNT('Table2'[Response]))
return
IF(_discount2<_discount1,"Warning",_discount2)

(3) Then the result is as follows.

vtangjiemsft_0-1668591655386.png

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.