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.
By customer ID, I am trying to rank order records but only when columnA = true. If not true/false, then the value can be 0.
Is this possible using Table.AddRankColumn?
If not, is there a way to rank order records only when the value is true?
Thank you
Give something like this a go, where you group by customer and columnA to conditionally add a rank
Copy this example into a new blank query
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZZE7EsIwDETv4jpF9LOkkgIqKj5VJve/BtgGJmYLN2/W8ltr28rj9jyXpdT3kdBa9uXHqDFTPzJubGU5MhksgTFNOW3M1/HG5XS9N+gNivIx2GVIpoHRBzJBTilxYFWCy+krGApVaPd3tzNxbKys0E6NJplhnQEDgxQExQ0Y0fxd1l+pk81oTGhtgblkhh1rJDBXzEm1SWY04YrfEIaLjymXvV36NLAH42P9hX3LaxhC07f3/gI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnA = _t, #"Customer ID" = _t, Order = _t]),
GroupRows = Table.Group(Source, {"ColumnA", "Customer ID"}, {{"t", each if List.First([ColumnA]) = "TRUE" then Table.AddRankColumn( _, "Rank", {"Order", Order.Descending}) else Table.AddColumn( _, "Rank", each 0 ), type table [ColumnA=nullable text, Customer ID=nullable text, Order=nullable text, Rank=number]}}),
AddCustOrderRank = Table.ExpandTableColumn(GroupRows, "t", {"Order", "Rank"}, {"Order", "Customer Order Rank"})
in
AddCustOrderRank
Ps. Please mark this answer as solution when it helped you to resolve your question, thanks!
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.