Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I'm struggling creating a line chart showing running total over non-calendar (Gas) years, that would correctly perserve the order of the months.
Desired features:
Data (note the Category column for filter testing purposes)
For a calendar year, the solution is relatively simple, using TOTALYTD function
So the desired line chart would have Oct - Sept months on the x-axis, calculating running total across those months using GasYear (instead of Calendar year). The quantities should stay allocated to months as they are. Keep in mind that running total is starting in October (not Jan).
I was able to calculate the numbers correctly (using last argument into TOTALYTD function as "30/09"), but I'm really struggling to then plot the results on a line chart with the months in desired order (Oct - Sept) and correct Gas Years in legend.
Gas years for illustration
Attaching PBIX
Any help greatly appreciated,
Stefan
Solved! Go to Solution.
Hi @Anonymous ,
If you want to calculate YTD according to your fiscal year, I suggest you use the following dax code:
Q_YTD =
CALCULATE (
SUM ( 'Table'[Quantity] ),
FILTER (
ALL ( 'Table' ),
'Table'[Date] <= MAX ( 'Table'[Date] )
&& 'Table'[GasYear] = MAX ( 'Table'[GasYear] )
)
)
You can use a calendar table to sort the months on the X-axis by your fiscal year. Please follow the steps below:
Create a calendar table:
Date = CALENDAR(DATE(2020,1,1),DATE(2021,12,31))
Create month and fiscal month columns in the calendar table:
Month = FORMAT('Date'[Date].[Month],"MMM")
FYMonthNum =
VAR FYStartMonth = 10
RETURN
IF (
MONTH ( 'Date'[Date] ) >= FYStartMonth,
MONTH ( 'Date'[Date] ) - ( FYStartMonth - 1 ),
12 + MONTH ( 'Date'[Date] ) - ( FYStartMonth - 1 )
)
Sort the month column by FYMonthNum column:
Associate the calendar table with the original table:
Use Month as Axis :
Please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EW803EfvBQ1Muao92mfHsfABCxwe68n0sQSPeEDNx0cD6A?e=cp1cOE
Best Regards,
Dedmon Dai
Hi @Anonymous ,
If you want to calculate YTD according to your fiscal year, I suggest you use the following dax code:
Q_YTD =
CALCULATE (
SUM ( 'Table'[Quantity] ),
FILTER (
ALL ( 'Table' ),
'Table'[Date] <= MAX ( 'Table'[Date] )
&& 'Table'[GasYear] = MAX ( 'Table'[GasYear] )
)
)
You can use a calendar table to sort the months on the X-axis by your fiscal year. Please follow the steps below:
Create a calendar table:
Date = CALENDAR(DATE(2020,1,1),DATE(2021,12,31))
Create month and fiscal month columns in the calendar table:
Month = FORMAT('Date'[Date].[Month],"MMM")
FYMonthNum =
VAR FYStartMonth = 10
RETURN
IF (
MONTH ( 'Date'[Date] ) >= FYStartMonth,
MONTH ( 'Date'[Date] ) - ( FYStartMonth - 1 ),
12 + MONTH ( 'Date'[Date] ) - ( FYStartMonth - 1 )
)
Sort the month column by FYMonthNum column:
Associate the calendar table with the original table:
Use Month as Axis :
Please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EW803EfvBQ1Muao92mfHsfABCxwe68n0sQSPeEDNx0cD6A?e=cp1cOE
Best Regards,
Dedmon Dai
HI @v-deddai1-msft ,
This is StefanZ - your solution works, thank you so much for you effert.
And apologies for not marking your answer as as correct, I'm unable to log in with my original accout, I don't know why. The Power Bi Community sign in protocols are really complicated.
Kind Regards
Stefan
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
123 | |
78 | |
48 | |
38 | |
37 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |