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,
I have a line chart visualization with the Financial Year on the Legend. This implies one line for each year starting from 1994 till 2019.
The requirement is to only show the latest 5 years by default and have the other years available for selection via slicer etc. So at present the default view will be years 2019,2018,2017,2016 and 2015. Rest of the years
How to achieve this?
Thanks,
Vishy
Hi @vishy86 ,
I create a sample you can have a try.
Calendar = CALENDARAUTO() Year = YEAR('Calendar'[Date]) Year = YEAR('Table'[Date])
last5 = var sel = SELECTEDVALUE('Calendar'[Year]) var curr = YEAR(TODAY()) var last5 = curr - 4 var a = CALCULATE(SUM('Table'[ Sales]),FILTER('Table','Table'[Year]<=curr && 'Table'[Year] >=last5)) var b = CALCULATE(SUM('Table'[ Sales]),ALL('Table'[Year]),FILTER('Table','Table'[Year] = sel)) return IF(ISFILTERED('Calendar'[Year]),b,a)
Note : The year of the slicer is from the calendar table. And the year of the line chart is from the original table.
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Xue,
My bad for not making my exact requirement clear.
I have a line chart at present with -
Axis: Accident Year Age which is a calculated column based on a formula.
Values: Calculated Measure based on another formula.
Legend: Financial Year
So the line graph gets plotted and shows 26 lines, one each for each financial year from 1994 to 2019.
The requirement is to have the same line chart as above with only latest 5 financial years shown i.e. 2015 to 2019. So only 5 lines and the rest of the years are available for selection via slicer if user wants to see the other years.
In your sample graph, you have the financial year on the axis which is not the case here.
Let me know if you have additional queries.
Thanks,
Vishy
Hi @vishy86 ,
Don't know if this answer is still on time, but you can do one of 2 things:
Filter = IF(SELECTEDVALUE('Table'[Year]) >= YEAR(TODAY()) - 5;1;BLANK())
Hope this helps.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCovering 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 |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |