I need to create 2 buttons for my report which filter ALL of the visuals on my page based on multiple conditions. I have tried using bookmarks with buttons but my issue is that you can only use bookmarks with slicers and my conditions are slightly complex.
I need to filter my visuals in two ways.
- Low Performing:
This should apply the following conditions
‘ Count of Patients < 2’ && ‘Count of Patients > 0 ‘
- Non Performing:
This should apply the following conditions
-‘Count of Patients = 0’
OR
-‘Start Date IS NOT blank && Count of Patients is either blank OR Count of Patients <1’
So I want two buttons on my page that will each filter my data based on the conditions above. If a viewer was to select ‘Non-Performing’ button they will see a filtered view of the data where EITHER the patient count is 0 OR where there is a non blank start date AND the count of patients is either 0 or blank. If a viewer was to select ‘Low-Performing’ button they will see a filtered view of the data where the patient count is less than 2 but more than 0.
I have been struggling to recreate this. Firstly I tried to use slicers and then hiding them, and then adding a bookmark to the button but I couldn’t create a slicer for the non performing.
Secondly, I created a new table which had one column with the two filter names (low and non performing). I then wrote a measure to attempt to include these filters – but the issue with this was that I could only apply it to one visual not the entire page.
ANY and all suggestions welcome. I have become super frustrated figuring this out and I am sure that I am overcomplicating this….
Thanks 🙂
CODE for the measure:
BUTTONMeasure =
VAR Cur_Sel=
SELECTEDVALUE('Buttons'[Preset Code])
VAR _Site =
SELECTEDVALUE('Historical Study by Site & PI'[Site])
VAR _a =
CALCULATETABLE(
VALUES('Historical Study by Site & PI'[Site]),
FILTER(
ALL('Historical Study by Site & PI'),
'Historical Study by Site & PI'[Count Patients Randomised] <2
&& 'Historical Study by Site & PI'[Count Patients Randomised] >0
)
)
VAR _b =
CALCULATETABLE(
VALUES('Historical Study by Site & PI'[Site]),
FILTER(
ALL('Historical Study by Site & PI'),
'Historical Study by Site & PI'[RTE] <> BLANK()
&& 'Historical Study by Site & PI'[Count Patients Screened] <1
)
)
VAR _c =
CALCULATETABLE(
VALUES('Historical Study by Site & PI'[Site]),
FILTER(
ALL('Historical Study by Site & PI'),
'Historical Study by Site & PI'[Count Patients Screened]=0
)
)
VAR _val =
SWITCH(
Cur_Sel,
"Low Performing Sites", IF (_Site IN _a,1),
"Non Performing Sites", IF (_Site IN _b && _Site IN _c,1)
)
RETURN
IF ( ISFILTERED(Buttons[Preset Code]), _val,1)
EXAMPLE Data Table:
Name | Address | Count Patients | Start Date |
---|---|---|---|
George | 123 lane | 4 | 19/01/2022 |
Julia | 456 Street | 0 | 01/01/2020 |
Nathan | 829 Av | 02/01/2024 | |
Felicity | 43rd Street |