The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi Guys
I wanted to know how can we calculate Previous fiscal year total sales.Currently my YTD dax is: TOTALYTD(SUM(Table1[Sales]),Date[Date],ALL(Date),"3/31")
Please help
To be able to carry out fiscal year calculations you have to have a fiscal calendar set up. Once you have it, you can use this formula:
[Total Sales PFY] =
// There must be a hidden integer field in the Calendar
// called FiscalYearNumber.
var __currentFiscalYear = SELECTEDVALUE( Calendar[FiscalYearNumber] )
var __totalpfy =
calculate(
[Total Sales],
Calendar[FiscalYearNumber] = __fiscalYear - 1
)
return
__totalpfy
This is the only way to deal with fiscal calendars - you have to have a proper one in the model and write the logic yourself. There is no fiscal time-intel built-in because there are too many ways to have fiscal calendars set up whereas there is only one standard calendar.
Best
D
@AnonymousCan you help me creating that table?
Try This
Hope this will work
Total Sales LY = CALCULATE( [Total Sales], DATESYTD( Dates[Date] ) )
@Anonymous thanks for the artilce!
Hello @Anonymous
Try following measures:
Total Orders = SUM(dtTable[Order Quantity])
YTD Orders = CALCULATE([Total Orders],DATESYTD('Calendar'[Date],"3/31"))
YTD Prev Year = CALCULATE([YTD Orders], SAMEPERIODLASTYEAR('Calendar'[Date]))
It will give you the desired output.
Cheers!
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Connect on LinkedIn
@vivran22 Thanks for the solution but again my YTD is coming out correct but the Previous Year is not coming out correct.Can't figure out why
@Anonymous Can you share the sample data file?
Cheers!
Vivek
https://www.vivran.in/
Connect on LinkedIn
Let's assume your current YTD measure works as you would like.
YTD = TOTALYTD(SUM(Table1[Sales]),Date[Date],ALL(Date),"3/31")
Create a New Measure -
YTD LY = CALCULATE( YTD, DATEADD( dDATES[DATE], -1, YEAR )
@AlexAlberga727Not working its just returning me the previous calendar year .Please note that my YTD measure is working fine according to my FY year.
try sameperiodLastyear.
Thanks,
Pravin
User | Count |
---|---|
15 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
23 | |
14 | |
13 | |
8 | |
8 |