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 guys,
I have a calendar table and a date table and I am trying to create a chart that shows the monthly sales until the selected date of the last year.
So, for example:
a) If I select June it should show the following chart:
b) If I select October, it should show the following chart:
All of the data should be from the last year of calendar table.
Is there a way to get it?
I tried this way: https://community.powerbi.com/t5/Desktop/Show-data-until-selected-month/m-p/705571 but I am having problems with the measure 'Compare to' and I don't know how to do it with just the last year of calendar table.
Thanks in advance.
Regards.
Solved! Go to Solution.
Hi @PwrBI01 ,
Based on my test , you firstly need to create a new table with MonthName column for slicer using the following formula:
ForSlicer = DISTINCT(SELECTCOLUMNS('Calendar',"MonthNo",[Date].[MonthNo],"MonthName",[Date].[Month]))
Then try this:
Measure =
var _lastYear=MAXX(ALL('Calendar'),YEAR([Date]))
var _month=MAX('ForSlicer'[MonthNo])
return CALCULATE(SUM('Date'[Value]),FILTER('Date',YEAR([Date])=_lastYear && MONTH([Date])<=_month))
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @PwrBI01 ,
Based on my test , you firstly need to create a new table with MonthName column for slicer using the following formula:
ForSlicer = DISTINCT(SELECTCOLUMNS('Calendar',"MonthNo",[Date].[MonthNo],"MonthName",[Date].[Month]))
Then try this:
Measure =
var _lastYear=MAXX(ALL('Calendar'),YEAR([Date]))
var _month=MAX('ForSlicer'[MonthNo])
return CALCULATE(SUM('Date'[Value]),FILTER('Date',YEAR([Date])=_lastYear && MONTH([Date])<=_month))
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
106 | |
104 | |
77 | |
68 | |
61 |
User | Count |
---|---|
148 | |
107 | |
106 | |
82 | |
70 |