Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, so I have to implement sparklines in my table using dax code. I found exmaples online that worked by generating a SVG image!
However, I want to modify the code and seem to be hitting some hard ends. This code generates a svg sparkline that takes into Months (MonthID), and fully reacts depending on how I filter the visual. So, if I filter the last year, my sparklines show only the months for that year. However, I need them to show the last 12 months regardless of year. I know how to do this in general, but I can't understand what I need to modify. I tried modifying xMinDate = MAX('History'[MonthID]) -12 but it's not working. Just moving the graph a bit. I am fairly sure I need to modify something in the bolded piece of code below. Any help would be appreciated!
Hi @Anonymous ,
Try :
VAR XMinDate = MIN(DATE(YEAR(TODAY())-1,MONTH(TODAY()),1))
VAR XMaxDate = max(DATE(YEAR(TODAY()),MONTH(TODAY()),1)-1)
And how table 'History' get ?
Best Regards
Lucien
@Anonymous , You can try a measure like that if you need for last 12 month
Sales 12 month =
VAR _Cuur_start = eomonth(today(),-12)+1
VAR _Curr_END = Today()
return
calculate(sum(Sales[Sales Amount]),Sales[Sales Date] >= _Cuur_start && Sales[Sales Date] <= _Curr_END )
The problem is if you select 1 month and want 12 months, then month need to be selected from the last 12
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
Hi @amitchandak
Ive just been reviewing this post as I wanted to add sparklines to a KPI report.
Is there anyway of saying no matter what date you select in your filter the sparkine will then take that date and then go back to the previous 3 month.
So for instance,
if I select period end 30/6/2023 the sparline will show 30/4, 31/5, 30/6
if I select period end 31/5/2023 the sparline will show 31/3, 30/4, 31/5
Does that make sense and is this possible. You've been ace on other stuff for me so I was hoping you could work your magic again 🙂
Thank you
Kind regards
Karen
Is this resolved ? I am having same requirement . Do u have sample pbix file which is resolved ?
Hi @swasim
The way I fixed it was to create a new dataset and join the sparkline dataset to my main dataset and fixed the 6 month period I needed. Worked a treat
Thanks Karen
Is it possible to post the implementation pbix file if possible? . A sample one
Its not that easy to post a sample file as I'd have to recreate the dashboard which is quite big with sample data. Let me look in to it
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
19 |