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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
GINMED
Helper III
Helper III

Running totals by items with date slicer

Hallo, I'm a new one in Power Bi, and lokking for support!!!
I have issue regarding running totals previous month.

How can I get correct data for each item per location and in correct period

I have ised such formula:

Q **bleep** Previous M =
VAR TimeTravel =
CALCULATE ( MAX ( Dates[Date] ), DATEADD ( Dates[Date].[Date], -1, MONTH ) )

RETURN

SUMX(

FILTER (
ALL ( Dates ),
Dates[Date]<= TimeTravel
),
[Q]
)

 

But this one is incorect, tha data for each items for some of them doesn't work correctly, and total is incorect as well.

 

G.

1 ACCEPTED SOLUTION

Hi, finally that one formula works perfectly

Q **bleep** Previous M =
VAR Currentmonth = MAX(Dates[Date])
VAR PreviousMon = EOMONTH( Currentmonth,-1 )
RETURN
CALCULATE(sum(ITEM_Ledger_entry[Quantity]), Dates[Date]<=PreviousMon
)

View solution in original post

14 REPLIES 14
v-yalanwu-msft
Community Support
Community Support

Hi, @GINMED ;

Try it.

Q cum cum Previous M = 
CALCULATE(sum(ITEM_Ledger_entry[Quantity]),
FILTER(
    ALL('ITEM_Ledger_entry'),
    [Posting_Date] <=EOMONTH( MAX(Dates[Date]),-1
)))

The final output is shown below:

vyalanwumsft_1-1643787227322.png

vyalanwumsft_2-1643787243204.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, finally that one formula works perfectly

Q **bleep** Previous M =
VAR Currentmonth = MAX(Dates[Date])
VAR PreviousMon = EOMONTH( Currentmonth,-1 )
RETURN
CALCULATE(sum(ITEM_Ledger_entry[Quantity]), Dates[Date]<=PreviousMon
)

Hi, Thank you! this one works correctly per item for all of lacations, but when I want to see by correct location, tha data is incorrect again.

 

GINMED_0-1643798461500.png

 

v-yalanwu-msft
Community Support
Community Support

Hi, @GINMED ;

I'm sorry that I don't know that your demand is the total amount of last month. There is no date column in this table, so how to get the data of last month? Or could you please tell me what result you want to output?

 

Best Regards,
Community Support Team_ Yalan Wu

I use the Dates table which has realtionship with Item ledger Entry (Posting date).

I need cumulative data for previous Month per each item. I already have cumulative data for current period, but I need to find prevous month data:(

I already have tried many formulas, but none of them is correct:(

v-yalanwu-msft
Community Support
Community Support

Hi, @GINMED ;

Try it.

Q **bleep** Previous M =
IF (
    ISINSCOPE ( 'ITEM_Ledger_entry'[Year] ),
    CALCULATE (
        SUM ( 'ITEM_Ledger_entry'[Quantity] ),
        FILTER (
            ALLSELECTED ( 'ITEM_Ledger_entry' ),
            EOMONTH ( [Posting_Date], 0 )
                = EOMONTH ( MAX ( 'ITEM_Ledger_entry'[Posting_Date] ), -1 )
        )
    ),
    CALCULATE (
        SUM ( 'ITEM_Ledger_entry'[Quantity] ),
        FILTER (
            ALLSELECTED ( 'ITEM_Ledger_entry' ),
            EOMONTH ( [Posting_Date], 0 )
                <> EOMONTH ( MAXX ( ALLSELECTED ( ITEM_Ledger_entry ), [Posting_Date] ), 0 )
        )
    )
)

The final output is shown below:

vyalanwumsft_0-1643704048964.png

Or

Q **bleep** Previous M2 = 
IF (
    ISINSCOPE ( 'ITEM_Ledger_entry'[Year] ),
    CALCULATE (
        SUM ( 'ITEM_Ledger_entry'[Quantity] ),
        FILTER (
            ALL ( 'ITEM_Ledger_entry' ),
            EOMONTH ( [Posting_Date], 0 )
                = EOMONTH ( MAX ( 'ITEM_Ledger_entry'[Posting_Date] ), -1 )
        )
    ),
    CALCULATE (
        SUM ( 'ITEM_Ledger_entry'[Quantity] ),
        FILTER (
            ALL ( 'ITEM_Ledger_entry' ),
            EOMONTH ( [Posting_Date], 0 )
                <> EOMONTH ( MAXX ( ALLSELECTED ( ITEM_Ledger_entry ), [Posting_Date] ), 0 )
        )
    )
)


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Tha data for this formula is empty 

GINMED_2-1643708533151.png

 

v-yalanwu-msft
Community Support
Community Support

Hi, @GINMED ;

Like below:

https://community.powerbi.com/t5/Desktop/Get-last-value-from-another-table/td-p/2302083

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

You may download my PBI file from here.

v-yalanwu-msft
Community Support
Community Support

Hi, @GINMED ;

Perhaps it would be better to provide a file with sensitive information removed.

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

How can I put this file here? maybe I can sent it for you by email?

 

WBR, Ginta

v-yalanwu-msft
Community Support
Community Support

Hi, @GINMED ;

Try it.

Q **bleep** Previous M =
SUMX (
    FILTER ( ALL ( Dates ), EOMONTH ( [Date], 0 ) = EOMONTH ( MAX ( [Date] ), -1 ) ),
    [Q]
)

If this does not apply to your data, can you share a simple result after removing sensitive information and hoping to output?

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, thank you! 

but this one does not work

GINMED_0-1643619730551.png

I want to find the correct cumulative formula for Q  previous period

GINMED_1-1643621124320.png

 

 

GINMED
Helper III
Helper III

GINMED_0-1643198946934.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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