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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

How to get previous month sales using dax

I have multiple years and months data in this how to get recent previous month total sales .How system identify previous month on multiple years .

My requirment is once open dashboard I want Previous month total sales in card visualization . I will not select perticular date , automatically sytem will undersatand what is current month and current year based on it will give current previous month total sales .

1 ACCEPTED SOLUTION
Anonymous
Not applicable
3 REPLIES 3
Reddy5833
Helper II
Helper II

Previous Month Sales =
Var
MonthNumber = IF( MONTH(TODAY())-1 = 0, 12,MONTH(TODAY())-1 )
Var
YearNumber = IF(MonthNumber = 12, YEAR(TODAY()) -1, YEAR(TODAY()))

Return

IF(
ISBLANK(CALCULATE(Sum(Table[sales]), FILTER (ALL('Date'), 'Date'[cal_year] = YearNumber && 'Date'[cal_month] = MonthNumber)))
,0
,CALCULATE(Sum(Table[sales]), FILTER (ALL('Date'),'Date'[cal_year] = YearNumber && 'Date'[cal_month] = MonthNumber))
)
Anonymous
Not applicable

Anonymous
Not applicable

Thanks it's useful based on that implemented getting correct result . 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors