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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Robin96
Helper II
Helper II

Calculate previous week measure doesnt work

Hey all,

i have been having trouble with this dax for quite some time now.. and i really need to figure this out.

1. on the first week i want cash balance.
IF(SELECTEDVALUE('date'[year_week]) = calculate(MIN('date'[year_week]), ALLSELECTED('Date'[Week])),[Cash balance],0)5


2. on the 2nd week i want net cashflow same week + previous week cash balance.

IF(SELECTEDVALUE('date'[year_week]) = calculate(MIN('date'[year_week])+1, ALLSELECTED('Date'[Week])),[net cash + balance],0)


3. on the 3rd week i want net cashflow same week + the 2nd week value.
Then i want to use the same logic as the 3rd week measure until the end.

This spreadsheet is my desired output:

Robin96_0-1709735485358.png


This is my model:

Robin96_1-1709735530442.png


This is how the table looks now:

Robin96_2-1709735600610.png

i have figured out how to  calculate the row for week 1 and week 2. But not week 3.
On week 3 i want to use the net cashflow same week + previous week "Week 2 (Correct)" measure.

2 ACCEPTED SOLUTIONS
Mattiar
Resolver I
Resolver I

Hi Robin,

 

first of all, i don't understand why you have that kind of relationships between tables. 

You should have a star schema  with one directional among dimensions and facts.

An advice i can give u, is try to use new calculation visual with its functions previous row.

Otherwise you would have to construct a more complicated dax function where you could select the week you want on a TOPN function.
For example, inside a variable you make yourself a SUMMARIZE in which you put the weeks in order. And if necessary you call up the week number with a SELECTEDVALUE.

View solution in original post

Hey Mattiar,

Thanks for you response! The reason i have this kind of relationship is because this is just a "testing" report i made to understand and test these calculations. my actual report have a different kind of relation between tables.

i will check out the new calculation visual and see if that will work any better, thanks!

I would be happy if there is someone else here with an solution here also.

View solution in original post

2 REPLIES 2
Mattiar
Resolver I
Resolver I

Hi Robin,

 

first of all, i don't understand why you have that kind of relationships between tables. 

You should have a star schema  with one directional among dimensions and facts.

An advice i can give u, is try to use new calculation visual with its functions previous row.

Otherwise you would have to construct a more complicated dax function where you could select the week you want on a TOPN function.
For example, inside a variable you make yourself a SUMMARIZE in which you put the weeks in order. And if necessary you call up the week number with a SELECTEDVALUE.

Hey Mattiar,

Thanks for you response! The reason i have this kind of relationship is because this is just a "testing" report i made to understand and test these calculations. my actual report have a different kind of relation between tables.

i will check out the new calculation visual and see if that will work any better, thanks!

I would be happy if there is someone else here with an solution here also.

Helpful resources

Announcements
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.