Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
Using the sample table below - is it possible to get the first non-zero value using Power Query?
I understand I can possibly do this via DAX but there are over 100k rows and it seems wasteful to load that much data into the report so I am taking the PQ route. I also understand, I can possibly use Pivot in this case however, the RN (Row Number) goes as far as RN=39. I'm thinking maybe convert the VAL column to a text column and then merge them into one but how do I make sure I am getting all pivoted VAL columns upon refresh?
| ID | VAL | RN | ||
| 1001404038 | 2393.64 | 1 | ||
| 1001459253 | 562.25 | 1 | ||
| 1001463837 | 0 | 1 | ||
| 1001463837 | 3252.24 | 2 | ||
| 1001478049 | 4606.74 | 1 | ||
| 1001478049 | 4601.74 | 2 | ||
| 1001478049 | 4601.74 | 3 | ||
| 1001478049 | 4601.74 | 4 |
Output should be like this:
| 1001404038 | 2393.64 | 1 | ||
| 1001459253 | 562.25 | 1 | ||
| 1001463837 | 3252.24 | 2 | ||
| 1001478049 | 4606.74 | 1 |
Solved! Go to Solution.
and you can useed this code
Table.Group(#"Changed Type", {"ID"}, {{"Count",
each Table.FirstN(
Table.SelectRows(_, each _[VAL] > 0),1)
}})
and you can useed this code
Table.Group(#"Changed Type", {"ID"}, {{"Count",
each Table.FirstN(
Table.SelectRows(_, each _[VAL] > 0),1)
}})
pls see my video
https://1drv.ms/v/s!AiUZ0Ws7G26Ringrxdxj3drlNpFE?e=8vMDu4
=Table.Group(#"Changed Type", {"ID"}, {{"Count",
each Table.SelectRows(
Table.AddIndexColumn( Table.SelectRows(_, each _[VAL] > 0),"Indx",1,1), each _[Indx]=1)
}})
it's not very clear what you want
explain again and provide an example of the result you want to get
THanks, I've edited the post to show the requested output.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.