Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The 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.

Reply
Anonymous
Not applicable

PTD Last year based on a slicer that point to a certain date today (trying to get partial PTD LY)

 

The formula below capture accurately the whole, full period of the previous year.
However,
I am trying to capture the sum of the prior period (PTD) based on licer that points to a specific date today.  (other words, trying to get partial PTD).
example: if date slicer points to 12/10/2023 then I am trying to get total of 12/1/22 thru 12/10/2022 (PreviousYear DAX formulas won't work here, because our calendar is non-fiscal)
 
PTD_PY =
VAR __Maxdate= Max(calendar_mapping[Date])
VAR __Period= MAX (calendar_mapping[Period])
VAR __PrevYear= YEAR(__MaxDate)-1
VAR __Table=FILTER(ALL(calendar_mapping),[Period]=__Period && YEAR([DATE])=__PrevYear &&[Date]<=__Maxdate)
VAR __PTDLY=SUMX(__Table,[Net Sales])
RETURN
__PTDLY
2 REPLIES 2
Fowmy
Super User
Super User

@Anonymous 
Please share a PBIX file with your custom date table and a dummy fact table. You can share it through Google Drive or One Drive link here. 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors