The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Solved! Go to Solution.
Hi there @dyabes
Can you clarify what you're trying to do?
If you're trying to create a calculated table that responds to a slicer selection, that's not possible, as any table is part of the dataset and not affected by filters in any report. In this case, SELECTEDVALUE will likely return a blank value.
Also, the DAX expression in your post ends with
RETURN __dateoffset
Is it mean to be this?
RETURN __sparklinecalendar
If you want to display the sparkline only for a certain range of dates, I would recommend creating the new Calendar table for the maximum possible range, then using a measure for the sparkline that is nonblank only for the required dates.
For example, if you first create 'Sparkline Calendar' (plus set up relationships and mark it as a date table), then you could write a measure like this to limit the dates for which nonblank values are returned:
Sparkline Measure =
VAR __dateoffset =
SELECTEDVALUE ( vis_SparklineOffset[vis_SparklineOffset] )
VAR __maxdate =
CALCULATE ( MAX ( Orders[OrderDate] ), REMOVEFILTERS () )
RETURN
CALCULATE (
[Existing Measure],
KEEPFILTERS (
DATESINPERIOD ( 'Sparkline Calendar'[Date], __maxdate, - __dateoffset, DAY )
)
)
Hi there @dyabes
Can you clarify what you're trying to do?
If you're trying to create a calculated table that responds to a slicer selection, that's not possible, as any table is part of the dataset and not affected by filters in any report. In this case, SELECTEDVALUE will likely return a blank value.
Also, the DAX expression in your post ends with
RETURN __dateoffset
Is it mean to be this?
RETURN __sparklinecalendar
If you want to display the sparkline only for a certain range of dates, I would recommend creating the new Calendar table for the maximum possible range, then using a measure for the sparkline that is nonblank only for the required dates.
For example, if you first create 'Sparkline Calendar' (plus set up relationships and mark it as a date table), then you could write a measure like this to limit the dates for which nonblank values are returned:
Sparkline Measure =
VAR __dateoffset =
SELECTEDVALUE ( vis_SparklineOffset[vis_SparklineOffset] )
VAR __maxdate =
CALCULATE ( MAX ( Orders[OrderDate] ), REMOVEFILTERS () )
RETURN
CALCULATE (
[Existing Measure],
KEEPFILTERS (
DATESINPERIOD ( 'Sparkline Calendar'[Date], __maxdate, - __dateoffset, DAY )
)
)
Thank you so much!
You are correct, I meant the measure be RETURN __sparklinecalendar.
I didn't realize I was actually using a slicer to filter a table of the dataset instead of it's result. It make sense how that can result to a lot of ambiguity.
Thank you for the solution. I will give it a go!
Cheers,
David
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
20 | |
18 | |
18 | |
14 | |
13 |
User | Count |
---|---|
38 | |
32 | |
22 | |
19 | |
18 |