Forum Discussion
gmasta1129
Resolver I
3 years agoFormula to pull in previous day balance
Hello, I am looking to pull the previous run date (second column) USD balance (7th column) if the "if value date/Run date" column is equal to "Y". For example, the new column should c...
- Anonymous3 years ago
Hi gmasta1129 ,
Please adjust the measure with below dax formula:
Measure = VAR cur_rk = [RK] VAR cur_flexacct = SELECTEDVALUE ( 'Table'[flex_acct] ) VAR cur_cd = SELECTEDVALUE ( 'Table'[if ValueDaate/Run Date] ) VAR tmp = FILTER ( ALL ( 'Table' ), 'Table'[flex_acct] = cur_flexacct && [RK] = cur_rk - 1 ) VAR _val = CALCULATE ( MAX ( 'Table'[usd_balance] ), tmp ) VAR cur_rd = SELECTEDVALUE ( 'Table'[Run Date] ) VAR _pre_date = CALCULATE ( MAX ( 'Table'[Run Date] ), tmp ) VAR cd = DATEDIFF ( cur_rd, _pre_date, DAY ) RETURN IF ( DAY ( cur_rd ) = 1 && cd <> 1, 0, IF ( cur_cd = "N", 0, _val ) )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.
gmasta1129
Resolver I
3 years agoAnonymous The formula above is pulling all zeros even when there is a balance in the previous day.
I think the issue is the return formula.
RETURN IF ( DAY ( cur_rd ) = 1 && cd <> 1, 0, IF ( cur_cd = "N", 0, _val ) )
It is correct in this scenario since the last negative balance was on 8/2 and there was no balance on 10/31
But this scenario has a balance as of 10/31 (previous day) and it is pulling 0 when I should be seeing -3.8 million