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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
felixzhao123
Regular Visitor

Calculate the Inventory $ of the Last Week in Previous Month

Hi,

I have a dataset which includes weekly inventory data of my company. I would like to compare latest inventory $ against the end of last month. However, normally there are four weeks data in previous month, and i would like to use the last week's data in previous month as the ending inventory $. A short example would be as below:

felixzhao123_0-1705290976931.png

The latest inventory $ is Jan 10 2024 and i would like to get the inventory of Dec 27 2023 inventory $ even though there is another week (Dec 20).

How can i achieve this with DAX?

 

Thanks,

Felix

 

1 ACCEPTED SOLUTION
saurabhtd
Resolver II
Resolver II

@felixzhao123  Here is the DAX logic which might work in your case. 

Inventory Last Week in Previous Month = 
VAR CurrentDate = TODAY()
VAR LastWeekPreviousMonth = 
    CALCULATE(
        MAX('Table'[Data Cut-off Date]),
        FILTER(
            ALL('Table'),
            MONTH('Table'[Data Cut-off Date]) = MONTH(EOMONTH(CurrentDate, -1))
            && YEAR('Table'[Data Cut-off Date]) = YEAR(EOMONTH(CurrentDate, -1))
        )
    )
RETURN
    CALCULATE(
        SUM('Table'[Sum of Inv USS]),
        'Table'[Data Cut-off Date] = LastWeekPreviousMonth
    )

 

View solution in original post

3 REPLIES 3
felixzhao123
Regular Visitor

@saurabhtd your method works perfect! Thanks and have already accepted as solution. Thanks!

@felixzhao123 You are welcome.

saurabhtd
Resolver II
Resolver II

@felixzhao123  Here is the DAX logic which might work in your case. 

Inventory Last Week in Previous Month = 
VAR CurrentDate = TODAY()
VAR LastWeekPreviousMonth = 
    CALCULATE(
        MAX('Table'[Data Cut-off Date]),
        FILTER(
            ALL('Table'),
            MONTH('Table'[Data Cut-off Date]) = MONTH(EOMONTH(CurrentDate, -1))
            && YEAR('Table'[Data Cut-off Date]) = YEAR(EOMONTH(CurrentDate, -1))
        )
    )
RETURN
    CALCULATE(
        SUM('Table'[Sum of Inv USS]),
        'Table'[Data Cut-off Date] = LastWeekPreviousMonth
    )

 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.