Forum Discussion
Customized filter behavior with button/slicer etc
Hi,
I'm new to PowerBI and I'm looking for a way create a custom filter.
I want to create some buttons that would help me apply filters that I want into the dashboard (image below). The idea is to include all records if viewer choose "Yes" in "include bonus" and exclude only the bonus records if they choose "No". I also need the filter to apply to all of my other reports and not just the current one.
If I create a calculated column that has "no" in records that are not bonus and "yes" in records that are bonus, I can create a slicer but that slicer is going to have 3 options (include all/exclude one or the other), however I only want to show users these 2 options of including all or excluding the bonus.
I also tried looking at buttons and bookmarks to change between views, however the bookmark will lead viewer to a separate view and thus all other selections outside of the bookmark button will not be kept.
Is there any way I can do this in PowerBI?
You could do this by creating a disconnected table with single column with 2 values "YES" and "NO"
Then you could create a measure like the following
Total Amount = VAR _includeBonus = SELECTEDVALUE('Include Bonus'[Include Bonus]) RETURN IF(_includeBonus = "NO", CALCULATE( SUM('Table'[Amount]), KEEPFILTERS('Table'[Bonus] = "NO")), SUM('Table'[Amount]))I've attached a copy of my test file to this post if you are interested.
5 Replies
- d_gosbell
Super User
You could do this by creating a disconnected table with single column with 2 values "YES" and "NO"
Then you could create a measure like the following
Total Amount = VAR _includeBonus = SELECTEDVALUE('Include Bonus'[Include Bonus]) RETURN IF(_includeBonus = "NO", CALCULATE( SUM('Table'[Amount]), KEEPFILTERS('Table'[Bonus] = "NO")), SUM('Table'[Amount]))I've attached a copy of my test file to this post if you are interested.
- LinhNguyen
Helper II
Awesome! That's exactly what I was looking for.
One more question: I'll need to create a time filter like in the picture (year to date, quarter to date, month to date). What do you think is the best way to do that? I suppose I shouldn't use the same approach because if so, for each column in my table, I'll need to create 6 scenarios (with/without bonus for 3 time periods).
I've marked your previous reply as the solution but please let me know if you see any other way to do this.
Thank you!!!
- AnonymousNot applicable
One question similar to this.
What if 'Include Bonus' Slicer has 10 different values and enabled for selecting multiple values.
in this case how do I check if only 'Yes' is selected.