Forum Discussion
Dynamic YTD with Month slicer
- Anonymous1 year ago
Hi WaninGNighT
Thanks for your pbix file, I can't reply to private messages due to policy reasons, please refer to the solution below, I hope it helps.
1. You should create the slicer using the 'Year' and 'Month' fields from the disconnected date table_'Slicer Date', rather than the fields in the 'Dim Date' table.
2. Create the following measures:YTD/QTD/MTD = SWITCH( SELECTEDVALUE('Time Intelligence'[Period]), "YTD", CALCULATE([Total Sales Amount], DATESYTD(Dim_Date[Date])), "QTD", CALCULATE([Total Sales Amount], DATESQTD(Dim_Date[Date])), "MTD", CALCULATE([Total Sales Amount], DATESMTD(Dim_Date[Date])) )New YTD/QTD/MTD = VAR SelectedYear = SELECTEDVALUE(Slicer_Date[Year]) VAR SelectedMonth = SELECTEDVALUE(Slicer_Date[Month]) RETURN CALCULATE( [YTD/QTD/MTD], FILTER( Dim_Date, Dim_Date[Year] = SelectedYear && Dim_Date[Month] <= SelectedMonth ) )
3. Place the 'Month' or 'Month Name' field from the 'Dim Date' table and the measure 'New YTD/QTD/MTD' into the column chart.Here are my test results:
Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello anilelmastasi ,
Thank you for your answer, but it didn't solve my question. I tried your way of calculating measure ytd, when I select a month, the column chart still only shows one bar which is the selected month. The calculation of cumulative sales is correct, but I just want all the previous months to show on x-axis as well.