Forum Discussion
How to Create Dynamic Default Slicer Value?
- 2 years ago
I actually was able to crack this problem! I will attempt to break down how I achieved this.
I created a Slicer Table with:
Slicer Table = UNION( SELECTCOLUMNS( 'ORION - Posts', "PostName", 'ORION - Posts'[PostName] ), DATATABLE( "PostName", STRING, {{"Current Post"}} ) )Then I have a user table with the locations tied to their principal user names by email and use this measure to lookup the post name:
UserPostName = LOOKUPVALUE( 'UserLocationData'[PostName], 'UserLocationData'[email], USERPRINCIPALNAME() )Back in the Slicer Table, I created another measure to use the user's post name if "Current Post" is selected in the slicer.
SelectedPostName = IF( SELECTEDVALUE('Slicer Table'[PostName]) = "Current Post", [UserPostName], SELECTEDVALUE('Slicer Table'[PostName]) )The biggest issue I was having was that other measures would not calculate correctly. This is solved by adding a variable into each measure.
LES Count = VAR SelectedPost = IF( SELECTEDVALUE('Slicer Table'[PostName]) = "Current Post", [UserPostName], SELECTEDVALUE('Slicer Table'[PostName]) ) VAR EmpCount = CALCULATE( SUM('DAFI - Personnel Data'[count]), 'DAFI - Personnel Data'[employeeType] = "Locally Employed Staff (LE Staff)", 'DAFI - Personnel Data'[site] = SelectedPost ) RETURN IF(ISBLANK(EmpCount), 0, EmpCount)However, I had to deactivate the relationships for:
- 'Slicer Table'[PostName] to 'ORION - Posts'[PostName]
- 'UserLocationData'[PostName] to 'ORION - Posts'[PostName]
Hi SensingFailure ,
Regarding your issue, it seems that you only have one quick measure in your visual, which should be the problem.Make sure there is at least one field in the visual other than a quick measure
Best Regards,
Wenbin Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.