Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi I have the data mentioned below and I wanted to create a New Val calculated column, as long as there is negative, make it zero and the record of the next row should subtract the negative values. In the following example, on 1/1/2025 role 2 has -25 and has to be zero in New Val and the next row which is role 3 val has 40, but New Val must 40-25, i.e. 15 must get it. I'm not sure how to create a calculated column to get values like the ones I described. Any help.
Solved! Go to Solution.
Hello @Syndicate_Admin
You can try with below DAX for calculated column
New Val =
VAR CurrentIndex = 'Table'[Index]
VAR CurrentVal = 'Table'[Val]
VAR PrevVal =
CALCULATE(
MAX('Table'[Val]),
FILTER(
'Table',
'Table'[Index] = CurrentIndex - 1
)
)
RETURN
IF(
CurrentVal < 0,
0,
IF(
PrevVal < 0,
CurrentVal + PrevVal, -- because PrevVal is negative
CurrentVal
)
)
Thanks,
Pankaj Namekar | LinkedIn
If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.
Hi @Syndicate_Admin
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.
Hi @Syndicate_Admin
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hello @Syndicate_Admin
You can try with below DAX for calculated column
New Val =
VAR CurrentIndex = 'Table'[Index]
VAR CurrentVal = 'Table'[Val]
VAR PrevVal =
CALCULATE(
MAX('Table'[Val]),
FILTER(
'Table',
'Table'[Index] = CurrentIndex - 1
)
)
RETURN
IF(
CurrentVal < 0,
0,
IF(
PrevVal < 0,
CurrentVal + PrevVal, -- because PrevVal is negative
CurrentVal
)
)
Thanks,
Pankaj Namekar | LinkedIn
If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 35 | |
| 34 | |
| 32 | |
| 27 |
| User | Count |
|---|---|
| 136 | |
| 96 | |
| 77 | |
| 67 | |
| 65 |