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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
CheenuSing
Community Champion
Community Champion

Hi @Anonymous 

 

Please check

https://community.powerbi.com/t5/Desktop/Calculating-a-value-based-on-current-and-previous-month/m-p/707517#M341594

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Reddy5833
Helper I
Helper I

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))
)
CheenuSing
Community Champion
Community Champion

Hi @Anonymous 

 

Please check

https://community.powerbi.com/t5/Desktop/Calculating-a-value-based-on-current-and-previous-month/m-p/707517#M341594

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Anonymous
Not applicable

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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