Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello All,
I'm not sure if this is even possible but I figured I would reach out to the community for help. I have two measures one for total views and the other for last 2 wks % change. I have these displayed in a table. I also have a line chart that if you select the day it changes both measures. I would only want it to change the first measure total views. Is this possible? Any help would be greatly appreciated!
No date selected in line chart:
Date selected in line chart ( I don't want my % measure to change):
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.
Modify your % Change Measure to ignore the filter coming from the line chart:
% 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)
@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.
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.
Hi @nleuck_101 ,
Thanks for rohit1991's and Bibiano_Geraldo's reply!
And @nleuck_101 , I'm sorry you haven't solved your problem yet, but with DAX alone it's actually very difficult for us to help you find your exact solution. Can you provide us with the data of all your data tables (with sample data instead of real data) and the relationship between each table? This will help us to understand your problem and find an accurate solution, thanks!
Best Regards,
Dino Tao
@Bibiano_Geraldo
I tried using ALL and it changed the calculation completely. I'm guessing it removed my current date filters in the measure. Below is my measure.
Hi @nleuck_101 ,
This is achieved by using the ALL or REMOVEFILTERS functions in DAX, which allow you to modify how filters affect the calculation. In your case, you want the total views measure to respond to the interaction from the line chart but ensure that the last 2 weeks % change measure ignores the interaction.
Can you share your DAX measures used?
User | Count |
---|---|
66 | |
60 | |
47 | |
33 | |
32 |
User | Count |
---|---|
86 | |
75 | |
56 | |
50 | |
45 |