Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi PBI Community,
I need some help with DAX Time Intelligence.
I am writing a DAX function that uses the sameperiodlastyear function on the calendar date to evaluate the total percentage in the 1 year period.
For example, the table A contains the percentages on Calendar_Date level and it is Fiscal Year 2021 data.
| Fiscal Year 2021 | |
| Calendar_Date | Percentage |
| 10/4/2020 | 1.50% |
| 10/5/2020 | 2.60% |
| 10/6/2020 | 3.70% |
| 10/7/2020 | 4.80% |
| 10/8/2020 | 5.50% |
| 10/9/2020 | 5.40% |
| 10/10/2020 | 2.30% |
I am writing a DAX function for Fiscal Year 2022 as below to :
Previous_Year_Percentage = CALCULATE([Percentage], Sameperiodlastyear(DATE[Calendar_Date]),ALLEXCEPT(Date,[Calendar_Date])
I am getting the below output from the above DAX statement :
| Fiscal Year 2022 | |
| Calendar_Date | Percentage |
| 10/3/2021 | 2.20% |
| 10/4/2021 | 1.50% |
| 10/5/2021 | 2.60% |
| 10/6/2021 | 3.70% |
| 10/7/2021 | 4.80% |
| 10/8/2021 | 5.50% |
| 10/9/2021 | 5.40% |
The issue with the output is it takes 2.20% which is not part of the Fiscal Year 2021 and instead the output should start with 1.50% on 10/3/2021 and so on.
Like below :
| Fiscal Year 2022 | |
| Calendar_Date | Percentage |
| 10/3/2021 | 1.50% |
| 10/4/2021 | 2.60% |
| 10/5/2021 | 3.70% |
| 10/6/2021 | 4.80% |
| 10/7/2021 | 5.50% |
| 10/8/2021 | 5.40% |
| 10/9/2021 | 2.30% |
I would appreciate any help on this.
Thanks,
Deepak
@amitchandak @tamerj1 @lbendlin @Sahir_Maharaj @Ritaf1983 @MFelix @johnt75
Solved! Go to Solution.
Hi Pat,
Thanks for responding.
I was able to resolve this using the below logic :
CALCULATE([Percentage],
DATEADD(Calendar_Date,-[Previous_Year_Calendar_Day_Count],DAY),
ALLEXCEPT(Date,[Calendar_Date])
-[Previous_Year_Calendar_Day_Count] moves the calendar days of current fiscal year to exact number of days based on previous year count.This helped in overlapping the fiscal year start date.
Thanks,
Thanks,
Deepak
Are you using MMDD or DDMM? Either way, instead of using time intelligence functions, one way would be to add Fiscal Year and a Day (or Month) of Fiscal Year columns to your Date table. You could then write a measure that moves the context to the previous Fiscal Year on the same Day of the the Fiscal year.
Pat
Hi Pat,
Thanks for responding.
I was able to resolve this using the below logic :
CALCULATE([Percentage],
DATEADD(Calendar_Date,-[Previous_Year_Calendar_Day_Count],DAY),
ALLEXCEPT(Date,[Calendar_Date])
-[Previous_Year_Calendar_Day_Count] moves the calendar days of current fiscal year to exact number of days based on previous year count.This helped in overlapping the fiscal year start date.
Thanks,
Thanks,
Deepak
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 22 | |
| 10 | |
| 10 | |
| 6 | |
| 5 |