Forum Discussion
Display a dynamic text value based on the selected values on two slicers
- 2 years ago
Hi Sebastian,
I think the base problem is you think SELECTEDVALUE does something different than what it actually does. It doesn't actually check that you've selected a value; it checks that there is only a single value for that column. This happens when you make a single selection in a slicer of course, but it's not the only way. (For more details, check out the documentation here.)
When you select Communications from Report Category, Report Category 2 is not blank. As you can see in your first screenshot, when you select Communications, Report Category 2 has only one value (""), therefore SelectedCategory2 is not blank, ISBLANK ( SelectedCategory2 ) returns FALSE and your measure returns SelectedCategory2 & " Expense report".
The DAX function it seems you are actually looking for is ISFILTERED. (I'm also using SWITCH instead of nested IF functions, for readability.)
Following the logic you laid out at the top of your post, what your logic flow in your measure should be is:
Report name display = VAR SelectedCategory = SELECTEDVALUE ( 'Sharepoint database'[Report Category] ) VAR SelectedCategory2 = SELECTEDVALUE ( 'Sharepoint database'[Report Category 2] ) VAR Result = SWITCH ( TRUE(), ISFILTERED ( 'Sharepoint database'[Report Category] ), SelectedCategory & " Expense Report", ISFILTERED ( 'Sharepoint database'[Report Category 2] ), SelectedCategory2 & " Expense Report", "Global Expense Report" ) RETURN ResultI would also recommend you set your slicers to single selections because I don't think you intend users to select more than one. Therefore, don't give them that option. 😄
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.
Hi Sebastian,
I think the base problem is you think SELECTEDVALUE does something different than what it actually does. It doesn't actually check that you've selected a value; it checks that there is only a single value for that column. This happens when you make a single selection in a slicer of course, but it's not the only way. (For more details, check out the documentation here.)
When you select Communications from Report Category, Report Category 2 is not blank. As you can see in your first screenshot, when you select Communications, Report Category 2 has only one value (""), therefore SelectedCategory2 is not blank, ISBLANK ( SelectedCategory2 ) returns FALSE and your measure returns SelectedCategory2 & " Expense report".
The DAX function it seems you are actually looking for is ISFILTERED. (I'm also using SWITCH instead of nested IF functions, for readability.)
Following the logic you laid out at the top of your post, what your logic flow in your measure should be is:
Report name display =
VAR SelectedCategory = SELECTEDVALUE ( 'Sharepoint database'[Report Category] )
VAR SelectedCategory2 = SELECTEDVALUE ( 'Sharepoint database'[Report Category 2] )
VAR Result =
SWITCH (
TRUE(),
ISFILTERED ( 'Sharepoint database'[Report Category] ), SelectedCategory & " Expense Report",
ISFILTERED ( 'Sharepoint database'[Report Category 2] ), SelectedCategory2 & " Expense Report",
"Global Expense Report"
)
RETURN Result
I would also recommend you set your slicers to single selections because I don't think you intend users to select more than one. Therefore, don't give them that option. 😄
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)
P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.
Hi Wilson,
thank you for your response.
I'm very grateful for your explanation about SELECTEDVALUE formula.
Albo, you have right about multiple selection on the slicer, bout please be informad, thet was only for preview, in the official version I used only single selection slicer.
Many thank you for your DAX measure. Everything working without issues.
Kind regards,
Sebastian
- Wilson_2 years ago
Memorable Member
Sebastian,
Perfect, thanks for the update. Happy I could help. 😄