The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello, I’m using a Sparkline generated via an API, and it’s working perfectly. Each dot corresponds to a week, allowing me to see the variation over time from the start of my dataset.
However, I’ve encountered a challenge: I want to filter my page data (e.g., using a slicer) to focus on specific weeks, such as Week 31 of the year. This should dynamically update all visuals on the page. However, I also want the Sparkline visual to always show the total data (ignoring any filters) to provide a full historical view.
I can’t disable the interaction between the filter and the Sparkline visual because I’m also using a card and a main measure on the page. These elements need to reflect the filtered data based on the selected date range.
Here’s the current code for my Sparkline:
As an example, here's how it looks like when no filter is applied :
And here is how it looks like when I filter on 3 weeks :
The data change to 5484 which is great but my sparkline also changes as well, I would like it to stay unfiltered.
Thank you in advance.
@BiCp81
I suggest you to build a disconected table with all dates from the date table of your model (newdates=all(ModelDates[dates])), and use it as the x-axis field on the chart that you want without filter.
adjust the measure for that chart with:
newmeasure= CALCULATE( [measure], KEEPFILTERS(TREATAS(newdates[date],modelDate[date])),ALL(Date))
please change the names of the measure and tables as needed.
I hope this helps. if so please accept as a solution. kudos are welcome.
Hello,
Thank you very much for your answer—it helped me realize that I was focusing on the wrong problem. Your method works perfectly when selecting a week number as you demonstrated. I really appreciate it!
However, the issue arises because I've implemented a custom "week" selector to quickly view data for the current week, the previous week, two weeks ago, etc., up to five weeks prior. This selector simplifies selecting recent weeks for analysis. Here's the DAX code I used to create the selector:
This DAX formula produces a selector that allows me to choose one of the last five weeks (S, S-1, S-2, etc.). For example, if I select S-2, it filters data for the seven days from December 16th to December 22nd.
Here’s where the issue arises: when I click on a week in this custom selector, the sparkline updates. However, the implementation you provided filters based on the week number (WEEKNUM), not my custom week selector. This causes inconsistencies, as the sparkline is not aligning with the custom week filter logic.
I suspect the issue lies in how the filter is applied in the sparkline calculation. I’m unsure how to adapt the sparkline implementation to work seamlessly with my week selector without breaking it.
I want my SparkLine to be on my weeknumber data, yet to ignore my week selector I've made.
Thank you again for your help and your fast response! I wish you a great evening.
Hi,
Here is modified dax:
With weeknumber filter:
The sparkline ignores filters while the measure changes.
Proud to be a Super User!
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |