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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

Rolling 4 Week Cash Flow

Hello, I am trying to generate a rolling 4 week cash flow. I am unable to send a file because of the private nature of the data so I will try to be succinct as possible.

 

My Weekly Cash Flow measure has the correct value:

Weekly Cash Flow =
[PW AP minus Current Week Cumulative AP]
+[PW Inventory minus Current Week Cumulative Inventory]
+[PW AR minus Current Week Cumulative AR]
+[PW Credit Cards minus Current Week Cumulative Credit Cards]
+[Net Operating Income]
 
My Rolling 4 Week Cash Flow is not correct:
Rolling 4 week Cash Flow =
CALCULATE(
    [Weekly Cash Flow],
    DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-28,DAY))
 
In the example below, the blue rectangle has the incorrect value, that value should be the sum of the values in the pink rectangle.
 
jch2shill_0-1662910279680.png

Can someone point out my error? Thank you.

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

Since you did not give a specific table, I had to create my own table for testing according to your description, please point out if there are any problems.

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1662965161055.png

2. add a new column with below dax formula

Index = RANKX('Table',[FW EndOfWeek],,ASC)

vbinbinyumsft_1-1662965305360.png

3. create a measure and add it to table visual

Measure =
VAR cur_index =
    SELECTEDVALUE ( 'Table'[Index] )
VAR tmp =
    FILTER (
        ALL ( 'Table' ),
        'Table'[Index] >= cur_index - 3
            && 'Table'[Index] <= cur_index
    )
VAR sum_for_4weekly =
    SUMX ( tmp, [Weekly Cash Flow] )
RETURN
    IF (
        cur_index < 4,
        SELECTEDVALUE ( 'Table'[Weekly Cash Flow] ),
        sum_for_4weekly
    )

vbinbinyumsft_2-1662965338461.png

Please refer the attached .pbix file.

 

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

 

Anonymous
Not applicable

Hello, I cleaned up my file and copied it here: https://drive.google.com/drive/folders/1k0Nw-TT7gOr0tOW6Nn9AmDKyoOPPTbNJ?usp=sharing Any additional help you can provide is appreciated.

Anonymous
Not applicable

Thank you for your help. My Weekly Cash Flow is in a different related table from my date table so I am getting this error:

jch2shill_0-1662984440995.png

 

Anonymous
Not applicable

Hi,

I might be looking at this the wrong way but, would this work?:

CALCULATE (
    SUM ( [Weekly Cash Flow]),
    DATESINPERIOD ('Date'[Date], MIN ( 'Date'[Date] ), -28, DAY )
)
Anonymous
Not applicable

Thank you for your reply. Regrettably the same value is created with this method.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors