Forum Discussion
Measure ignore interaction with another visual
Yes, you can prevent the percentage change measure from being affected by the selection in the line chart while still allowing the total views measure to change.
Solution: Use ALLSELECTED or REMOVEFILTERS
Modify your % Change Measure to ignore the filter coming from the line chart:
Updated DAX Measure for % Change
% Change =
VAR PrevPeriod =
CALCULATE(
SUM('Table'[Views]),
DATEADD('Table'[Date], -14, DAY),
REMOVEFILTERS('Table'[Date]) -- Ignores date selection
)
VAR CurrentPeriod =
CALCULATE(
SUM('Table'[Views]),
REMOVEFILTERS('Table'[Date]) -- Ignores date selection
)
RETURN
IF(PrevPeriod = 0, BLANK(), (CurrentPeriod - PrevPeriod) / PrevPeriod)
- nleuck_1011 year agoContinued Contributor
rohit1991
One quick note, if I select a date that is more than 2wks the calculation doesn't work. It changes the calculation.
Date selected more than 2 wks ago.- rohit19911 year agoSuper User
Hi nleuck_101 ,
Great question! You can definitely set it up so that your % change measure ignores the date selection from your line chart, while your total views measure still responds to it.
Just use REMOVEFILTERS or ALL on the date column inside your % change measure. This tells Power BI to always calculate the last two weeks based on the latest available date in your data, no matter what’s selected in the line chart.% Change = VAR LastAvailableDate = CALCULATE( MAX('Table'[Date]), REMOVEFILTERS('Table'[Date]) ) VAR PrevPeriod = CALCULATE( SUM('Table'[Views]), DATESINPERIOD('Table'[Date], LastAvailableDate, -14, DAY), REMOVEFILTERS('Table'[Date]) ) VAR CurrentPeriod = CALCULATE( SUM('Table'[Views]), DATESINPERIOD('Table'[Date], LastAvailableDate, 0, DAY), REMOVEFILTERS('Table'[Date]) ) RETURN IF(PrevPeriod = 0, BLANK(), (CurrentPeriod - PrevPeriod) / PrevPeriod)Your Total Views measure can remain as it is, so it’ll still react to date selections on your line chart. For the % change, using REMOVEFILTERS('Table'[Date]) ensures it always gives you the change over the latest two weeks, regardless of what’s selected elsewhere.
- nleuck_1011 year agoContinued Contributor