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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Get sum of quantity of current month - 2

Hi,

 I am looking to get sum of quantity by using following dax.

 

current month quantity = CALCULATE([Qty],Dates[Date],
FILTER(Dates,
Dates[Date] = MAX('Reporting Dates'[Date])
))
 
'Dates' is a date table containing dates till the entire year.
'Reporting Dates' is a table which has dates till current month.
 
I would like to alter the dax to show quantity for January end. i.e., current month March - 2.
 
I tried putting -2 after "MAX('Reporting Dates'[Date])" in the above dax, but it isnt working.
Any tips would be appriciated. 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , If no date is selected

 

or

 

2nd Last Month Today =

var _today =maxx( allselected('Reporting Dates')  , 'Reporting Dates'[Date])
var _min = eomonth(_today,-3)+1
var _max = eomonth(_today,-2)
return CALCULATE([Qty], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

2nd Last Month Today =
var _min = eomonth(today(),-3)+1
var _max = eomonth(today(),-2)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

Last Month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Arul
Super User
Super User

@Anonymous ,

try this

Two month back sales = 
CALCULATE (
    [Qty],
    FILTER (
        'Dates',
        MONTH ( 'Dates[Date] )
            = MONTH ( MAX ( Reporting Dates] ) ) - 2
    )
)

Thanks,

Arul





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


amitchandak
Super User
Super User

@Anonymous , If no date is selected

 

or

 

2nd Last Month Today =

var _today =maxx( allselected('Reporting Dates')  , 'Reporting Dates'[Date])
var _min = eomonth(_today,-3)+1
var _max = eomonth(_today,-2)
return CALCULATE([Qty], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

2nd Last Month Today =
var _min = eomonth(today(),-3)+1
var _max = eomonth(today(),-2)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

Last Month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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