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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Let's imagine a simple table:
| Index | City | Step |
| 1 | NYC | 1 |
| 2 | NYC | 0 |
| 3 | NYC | 0 |
| 4 | NYC | 0 |
| 5 | LA | 5 |
| 6 | LA | 0 |
| 7 | NYC | 7 |
| 8 | NYC | 0 |
How can I changes zeros in Step to the previous non zero value so to obtain the Goal coloumn?
| Index | City | Step | Goal |
| 1 | NYC | 1 | 1 |
| 2 | NYC | 0 | 1 |
| 3 | NYC | 0 | 1 |
| 4 | NYC | 0 | 1 |
| 5 | LA | 5 | 5 |
| 6 | LA | 0 | 5 |
| 7 | NYC | 7 | 7 |
| 8 | NYC | 0 | 7 |
I tried using an index coloumn and List.Range but it only works with the first row with zero (imagine processing row number #2, I can get the value in Step on the previous row which is 1, great. For row #3 unfortunately the previous value is 0).
Solved! Go to Solution.
Hi @pmonte ,
As the data sample you provided, I'd suggest you replace 0 with null and then use Fill Down to simply change the zero value to non zero value.
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @pmonte ,
As the data sample you provided, I'd suggest you replace 0 with null and then use Fill Down to simply change the zero value to non zero value.
The final output is shown below:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@pmonte , Try a new column like
new column =
var _ind = maxx(filter(Table, [City] = ealier([City]) && [Step] <>0), [Index])
var _1 = maxx(filter(table, [Index] =_ind ), [Step])
return
if(isblank(_1), [step], _1)
Hello @amitchandak and thanks a lot but this in DAX, I'd need to do this in Query M, any ideas?
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!