Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I need help with a Power BI scenario:
I have tried to create a DAX measure to compare the slicer selection with the table rows, but I am running into filter context issues.
Download .pbix
What is the recommended way to achieve this?
Thank you in advance!
Solved! Go to Solution.
Got it. With your current model, there is no way to have a slicer affect a measure in a visual without also affecting the overall filter on the visual. In case you thought of maybe addressing this with "Edit interactions," telling the slicer to not impact your visual will also stop the slicer from impacting the measure inside the visual.
So, to achieve what you want, you need to update your model with another calendar dimension table that is not related to your fact table. You can then use a measure with a virtual relationship between the disconnected calendar dimension and your fact table.
Quick notes:
1) I switched your relationship between your calendar dimension and fact to 1:* rather than *:*
2) I set a 1:* relationship from our original calendar to the disconnected calendar, so Dcalendar will filter Dcalendar_Selector, but not other way around
The new table to create:
Dcalender_Selector = Dcalender
Selector Calc =
IF(
CALCULATE(
NOT ISEMPTY( 'Table' ),
TREATAS( VALUES( Dcalender_Selector[Date] ), 'Table'[Data] ),
'Table'
),
"XXXXX"
)
Thank you so much for your help and detailed explanations! I just wanted to point out that one detail was missing, the solution didn’t show items without data, which was important for my scenario. Still, your guidance was extremely helpful, and thanks to your answers, I was able to solve my problem. I really appreciate your support!
Probably the most straightforward way, but somewhat of a blunt instrument, is to turn on "Show items with no data". Just right-click on any non-measure field in the field well and select.
Field | Sub Field | Field Value |
A | X | 10 |
B | X | 20 |
C | X | 30 |
D | X | 40 |
A | Y | 50 |
B | Y | 60 |
Blank Non A = CALCULATE( SUM( 'Table'[Field Value] ), KEEPFILTERS( 'Table'[Field] = "A" ) )
Thank you for your reply!
Turning on "Show items with no data" is helpful for displaying all months in the visual, but in my case, I need a solution based on a measure. I intend to use this measure for additional logic, such as marking "XXXX" for months after the selected value in the slicer.
I've attached a sample file to better illustrate my scenario.
If you have any DAX-based approaches for this kind of dynamic comparison and signaling, I would really appreciate it!
Thanks again!
Got it. With your current model, there is no way to have a slicer affect a measure in a visual without also affecting the overall filter on the visual. In case you thought of maybe addressing this with "Edit interactions," telling the slicer to not impact your visual will also stop the slicer from impacting the measure inside the visual.
So, to achieve what you want, you need to update your model with another calendar dimension table that is not related to your fact table. You can then use a measure with a virtual relationship between the disconnected calendar dimension and your fact table.
Quick notes:
1) I switched your relationship between your calendar dimension and fact to 1:* rather than *:*
2) I set a 1:* relationship from our original calendar to the disconnected calendar, so Dcalendar will filter Dcalendar_Selector, but not other way around
The new table to create:
Dcalender_Selector = Dcalender
Selector Calc =
IF(
CALCULATE(
NOT ISEMPTY( 'Table' ),
TREATAS( VALUES( Dcalender_Selector[Date] ), 'Table'[Data] ),
'Table'
),
"XXXXX"
)
@MarkLaf Hi! I was able to highlight the row corresponding to the value selected in the slicer in the table, following your guidance. Now, I’d like to know how I can make the value selected in the slicer appear in all rows of the table, that is, show the same value for every month. Could you help me with this? Thank you!
Do you just want the value selected in the slicer to be used in the measure?
Or do you want the whatever "XXXXX" is to be repeated? It wasn't super clear what you were doing in the measure given we were just working with string "XXXXX" but I assume that "XXXXX" was stand-in for some kind of calculation?
This may need tweaking depending on what you are doing with "XXXXX", but this works with a simple calc like SUM, which I used for testing:
Selector Calc All Rows = VAR _slicerSelect = CALCULATETABLE( VALUES( Dcalender_Selector[Date] ), REMOVEFILTERS( Dcalender ) ) RETURN IF( NOT ISEMPTY( 'Table' ), CALCULATE( SUM( 'Table'[VALOR] ), // <--- whatever your "XXXXX" calc is goes here TREATAS( _slicerSelect, 'Table'[Data] ), REMOVEFILTERS( 'Table' ) ) )
Thank you so much for your help and detailed explanations! I just wanted to point out that one detail was missing, the solution didn’t show items without data, which was important for my scenario. Still, your guidance was extremely helpful, and thanks to your answers, I was able to solve my problem. I really appreciate your support!
Hi, use a selectedvalue in a calculated measure to mark it as needed, here is the dax:
Marker =
VAR SelectedMonth = SELECTEDVALUE('DateTable'[MonthNumber])
VAR SelectedYear = SELECTEDVALUE('DateTable'[Year])
VAR CurrentMonth = MONTH(MAX('DateTable'[Date]))
VAR CurrentYear = YEAR(MAX('DateTable'[Date]))
RETURN
IF(
SelectedMonth = CurrentMonth &&
SelectedYear = CurrentYear,
"XXXXX",
BLANK()
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
72 | |
68 | |
41 | |
35 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
42 |