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 Everyone ,
here i have one question that i need subtraction of YTD of one year with YTD of another Year.
As i mentioned requirement in below screenshot.
Please Tell me is that possible the Difference of the YTD of this year - YTD of last year.
Thanks
Sandeep
Solved! Go to Solution.
Assuming you have a Calendar Table (if you don't, use the date field on current table), create YTD measure (change name of tables and columns):
VALUE YTD =
IF(
ISFILTERED('Calendar'[Date]);
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column.");
TOTALYTD(SUM('TABLE'[VALUE]; 'Calendar'[Date].[Date])
)Create Previous YTD measure:
VALUE PYTD =
VAR pytddate1 = DATEADD(DATEADD(DATEADD(ENDOFYEAR ( 'Calendar'[Date] );-1;YEAR);1;DAY);-1;YEAR)
VAR pytddate2 = DATEADD ( ENDOFMONTH ( 'Calendar'[Date] ); -1; YEAR )
RETURN
CALCULATE (
SUM['TABLE'[VALUE];
FILTER (
ALL ( 'Calendar'[Date] );
'Calendar'[Date]
>= pytddate1
&& 'Calendar'[Date] <= pytddate2
)
)Then calculate the difference:
VALUE PYTDG = [VALUE YTD] - [VALUE PYTD]
Hi @avulasandeep,
You need a calendar table as @Anonymous said, and please mark the right reply as answer if you have resolved your issue.
Thanks,
Angelia
Assuming you have a Calendar Table (if you don't, use the date field on current table), create YTD measure (change name of tables and columns):
VALUE YTD =
IF(
ISFILTERED('Calendar'[Date]);
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column.");
TOTALYTD(SUM('TABLE'[VALUE]; 'Calendar'[Date].[Date])
)Create Previous YTD measure:
VALUE PYTD =
VAR pytddate1 = DATEADD(DATEADD(DATEADD(ENDOFYEAR ( 'Calendar'[Date] );-1;YEAR);1;DAY);-1;YEAR)
VAR pytddate2 = DATEADD ( ENDOFMONTH ( 'Calendar'[Date] ); -1; YEAR )
RETURN
CALCULATE (
SUM['TABLE'[VALUE];
FILTER (
ALL ( 'Calendar'[Date] );
'Calendar'[Date]
>= pytddate1
&& 'Calendar'[Date] <= pytddate2
)
)Then calculate the difference:
VALUE PYTDG = [VALUE YTD] - [VALUE PYTD]
So, if you have a separate Date table, then you should be able to use time intelligence functions and the general format of those would be:
Sales YTD = TOTALYTD(Sum('Sales'[Revenue]),'Date'[Date])
Sales LY YTD = CALCULATE ([Sales YTD], SAMEPERIODLASTYEAR ('Date'[Date]))
Sales Var = [Sales YTD]-[Sales LY YTD]If you do not have a separate date table either create one or check out my Time Intelligence The Hard Way Quick Measure:
Well... I'm glad I also replied because I learned something... hehehe
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 63 | |
| 32 | |
| 31 | |
| 25 |