Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
I'm struggling with the DAX to calculate the running total for the Prior Year. The Running total for the current Financial year works fine though.
To get this working I have Two date tables as it always have to show the YTD data regardless of the month I select in the financial year. These are the results I'm getting. The Running total for the Prior Year is always blank and only shows up in previous Financial Year.
Month | Measure | Measure Running Total | Measure STLY | STLY Running Total |
Jul | 1403 | 1403 | 1248 | |
Aug | 1462 | 2865 | 604 | |
Sep | 951 | 3816 | 884 | |
Oct | 841 | 4657 | 1099 | |
Nov | 965 | 5622 | 1253 | |
Dec | 778 | 6400 | 1272 | |
Jan | 494 | 6894 | 839 | |
Feb | 632 | 7526 | 1276 | |
Mar | 1119 | 8645 | 1088 | |
Apr | 856 | 9501 | 1220 | |
May | 1253 | 10754 | 1339 | |
Jun | 1136 | 11890 | 1110 |
This is the Joins to the 2 Date Tables
This is the DAX I'm using:
//Current Year DAX
[MeasureValue]= CALCULATE(SUM('MeasureData'[MeasureResult]))
//Current Year Value
[Measure] =
VAR YearSelected = SELECTEDVALUE('DimDate'[Year])
RETURN
CALCULATE([MeasureValue], FILTER(ALL(DimDate), DimDate[Year] = YearSelected))
//Current Year Running Total
[Measure Running Total] = CALCULATE([Measure1], DATESYTD(DimDateYTD[YTDDateValue], "30/06"))
// Prior Year DAX
[Measure STLY] =
VAR YearSelected = SELECTEDVALUE('DimDate'[Year]) - 1
RETURN
CALCULATE([MeasureValue], FILTER(ALL(DimDate), DimDate[Year] = YearSelected))
// Prior Year Running Total
[Measure STLY RunningTotal] = CALCULATE([Measure1 STLY], DATESYTD(DimDateYTD[YTDDateValue], "30/06"))
Can anyone assist me with this please!!
Solved! Go to Solution.
@angelo2022 , Try like example
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"6/30"))
or
new column
Day of Year =datediff([Year Start date] , [Date],Day) +1
measures
YTD= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank]) && 'Date'[Day of Year] <= Max('Date'[Day of Year]) ))
LYTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])-1 && 'Date'[Day of Year] <= Max('Date'[Day of Year])))
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
@angelo2022 , Try like example
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"6/30"))
or
new column
Day of Year =datediff([Year Start date] , [Date],Day) +1
measures
YTD= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank]) && 'Date'[Day of Year] <= Max('Date'[Day of Year]) ))
LYTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])-1 && 'Date'[Day of Year] <= Max('Date'[Day of Year])))
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
Hi @amitchandak ,
Thanks for helping with this one, but could please help me again.
We have moved to the next financial Year (Jul 2022 to June 2023) but it doesn't seem to calculate a Running Totals for Current and Prior Months for Previous Financial Years unless I add the Year into the visual.
I had to adjust the Measure Running Total a little
From this:
//Current Year Running Total
[Measure Running Total] = CALCULATE([Measure1], DATESYTD(DimDateYTD[YTDDateValue], "30/06"))
To this:
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
29 | |
14 | |
11 | |
10 | |
9 |