Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
I need the PYTD function to give me just the total of sales for the same period last year as the current year period.
This is the formula I am using for YTD:
Solved! Go to Solution.
Hi,@CiaraCaryl
1.First I have created the following table and the column names and data are the data you have given:
2. Below are the measure I've created for your needs:
MEASURE =
VAR cdate =
CALCULATE (
MAX ( 'Combined Table'[QR Date] ),
FILTER (
ALLSELECTED ( 'Combined Table' ),
'Combined Table'[QR Date].[Year] = MAX ( 'Combined Table'[QR Date].[Year] )
)
)
RETURN
CALCULATE (
SUM ( 'Combined Table'[Quota Credit] ),
FILTER (
'Combined Table',
'Combined Table'[QR Date].[Year]
= YEAR ( cdate ) - 1
&& 'Combined Table'[QR Date] <= EDATE ( cdate, -12 )
)
)
3.Here's my final result, which I hope meets your requirements.
4.Here are some links that may be helpful if you have similar questions:
Solved: Need a help for Last Year YTD Data by Month select... - Microsoft Fabric Community
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi @CiaraCaryl ,
TOTALYTD and SAMEPERIODLASTYEAR are time intelligence functions, to use them, you need a dedicated calendar table. Without the calendar table, try a measure like:
PYTD =
VAR _todaylastyear = EDATE(MAX('Combined Table'[QR Date]), -12)
VAR _result =
CALCULATE(
SUM('Combined Table'[Quota Credit]),
FILTER(
ALL('Combined Table'[QR Date]),
'Combined Table'[QR Date])<_todaylastyear
&&YEAR('Combined Table'[QR Date])) = YEAR(_todaylastyear)
)
)
RETURN _result
hi @CiaraCaryl ,
TOTALYTD and SAMEPERIODLASTYEAR are time intelligence functions, to use them, you need a dedicated calendar table. Without the calendar table, try a measure like:
PYTD =
VAR _todaylastyear = EDATE(MAX('Combined Table'[QR Date]), -12)
VAR _result =
CALCULATE(
SUM('Combined Table'[Quota Credit]),
FILTER(
ALL('Combined Table'[QR Date]),
'Combined Table'[QR Date])<_todaylastyear
&&YEAR('Combined Table'[QR Date])) = YEAR(_todaylastyear)
)
)
RETURN _result
Hi,@CiaraCaryl
1.First I have created the following table and the column names and data are the data you have given:
2. Below are the measure I've created for your needs:
MEASURE =
VAR cdate =
CALCULATE (
MAX ( 'Combined Table'[QR Date] ),
FILTER (
ALLSELECTED ( 'Combined Table' ),
'Combined Table'[QR Date].[Year] = MAX ( 'Combined Table'[QR Date].[Year] )
)
)
RETURN
CALCULATE (
SUM ( 'Combined Table'[Quota Credit] ),
FILTER (
'Combined Table',
'Combined Table'[QR Date].[Year]
= YEAR ( cdate ) - 1
&& 'Combined Table'[QR Date] <= EDATE ( cdate, -12 )
)
)
3.Here's my final result, which I hope meets your requirements.
4.Here are some links that may be helpful if you have similar questions:
Solved: Need a help for Last Year YTD Data by Month select... - Microsoft Fabric Community
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
22 | |
17 | |
17 | |
11 | |
7 |
User | Count |
---|---|
27 | |
26 | |
13 | |
12 | |
12 |