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

View all the Fabric Data Days sessions on demand. View schedule

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.