0

In PowerBi, I have a table called Events and a ScenarioSlicerTable. I want the user to be able choose which Scenario to display, but I also want to always display rows where Scenario is blank. These are baseline rows.

I’ve tried this code, but the SelectedValue function always returns blank for me.

If (ISBLANK(Events[Scenario]),
TRUE(),
Events[Scenario]=SELECTEDVALUE(ScenarioSlicerTable[Scenario])

I know I could always have a multi select slicer and just beg the user to select blank and one other scenario, but that’s not very professional

Sample Data

Events Table

EventID EventName Scenario
1 Event A
2 Event B Scenario 1
3 Event C Scenario 2
4 Event D
5 Event E Scenario 1

ScenarioSlicerTable

Scenario
Scenario 1
Scenario 2

Expected Output when "Scenario 1" is selected

EventID EventName Scenario
1 Event A
4 Event D
2 Event B Scenario 1
5 Event E Scenario 1

DAX Attempted

If (ISBLANK(Events[Scenario]),
    TRUE(),
    Events[Scenario] = SELECTEDVALUE(ScenarioSlicerTable[Scenario])
)
2
  • could you pls provide some sample data and expected output? Commented May 15 at 8:25
  • @Ryan added example Commented May 15 at 8:31

1 Answer 1

0

try NOT to create relationship between two tables.

if it's always a single selection, you can try to create a measure

Measure =
IF (
    MAX ( 'Event'[Scenario] ) = MAX ( 'ScenarioSlicer'[Scenario] )
        || MAX ( Event[Scenario] ) = "",
    1
)

and add the measure to visual filter and set to 1

enter image description here

if you want a multiple selection, you can update the measure to

MEASURE 2 =
VAR _list =
    DISTINCT ( 'ScenarioSlicer'[Scenario] )
RETURN
    IF ( MAX ( Event[Scenario] ) IN _list || MAX ( Event[Scenario] ) = "", 1 )

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

this works in a table, but is there a way to get it to work in a bar chart also? I want to display some visuals for my data.
With your solution, the slicer seems to only work for Scenario 2 in a bar chart
could you pls paste the expected bar chart screenshot ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.