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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply

Dax to calaculate same period (till same date ) last year

Dhrutivyasa070_0-1707807899862.png

 as per image , 

in april sales is till 9th apr 2023 but in previous year it was till 30th april 

i want to calculate if  in selected year/month my store is working till 10 days only then calculate sum of only 10 days in last year same month . 

thanks in advance 

 

1 REPLY 1
tharunkumarRTK
Super User
Super User

@Dhrutivyasa-070 you can follow the below pattern

PY Sales = 
VAR MaxDate = EDATE(MAX(Sales [Date]), -12)
VAR MinDate = EDATE(MIN( 'Calendar' [Date]), -12)
VAR LYDates =
DATESBETWEEN(
'Calendar' [Date], MinDate, MaxDate)
RETURN CALCULATE (
[Total Sales],
LYDates )

Please don't forget to accept my solution if it helps. Thanks

Tharun

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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