Forum Discussion
Previous Balance Calculation Issue
- 7 years ago
Hi Rahulsingh,
Based on my test, you could refer to below steps:
Sample data:
Create two measures:
Index = RANKX(ALL(Table1),FIRSTNONBLANK('Table1'[Dates],'Table1'[Dates]),,ASC,Dense)Measure = var a=[Index]-1 return CALCULATE(SUM(Table1[Balance]),FILTER(ALL('Table1'),'Table1'[Index]=a))Result:
You could also download the pbix file to have a view:
https://www.dropbox.com/s/vgkl8c3yf5vccn0/Previous%20Balance%20Calculation%20Issue.pbix?dl=0
Regards,
Daniel He
- 7 years ago
Thank you v-danhe-msft it worked. Thanks a lot
I'd suggest using an index column in Power Query, then writing a DAX formula measure to get the value of the Index minus 1.
https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi
Last Value = var indexValue = MAX('YourTable'[Index])
RETURN
IF(
indexValue > 1,
CALCULATE(
SUM('YourTable'[Balance]),
ALL('YourTable'),
'YourTable'[Index] = (indexValue - 1)
),
0
)
- Rahulsingh7 years agoHelper I
Hi Anonymous
what does INDEX > 1 in your formula stand? When I use INDEX > 1 it's giving me an error
- Anonymous7 years agoNot applicable
Rahulsingh that should have been indexValue it represents an error trap for the occasion of where this calcules for the first row in the data (index = 1). That was just a silly typo on my part. I've updated the code.