This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi All
I am stuck in a scenario where i have assigned ranking to different Types.
Data contains repeated types values and i would like to get only 3 of these values in the result.
If 3 does not exist, top 2 type values to be my output. If same type exists pick any one type even if other values are different.
Consider the below scenario:
Solved! Go to Solution.
Hi @Anonymous ,
The following code should work for both scenarios. It uses two Group Bys to bundle up the [ID Type]s first, then to create the value lists:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8slMTs1LTlXSUTI0MjYxBdKOTs4gnlKsDrKsmbmFpQGQdnF1g8sGJBYXF+QXlQAFTEzNgGREZBSQNAJL+pdkpBYBecbGxkAysTg1HcRRio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID_Type = _t, ID_Num = _t, ID_Issuer = _t, Ranking = _t]),
groupIdType = Table.Group(
Source,
{"ID_Type"},
{
{"ID_Num", each List.First([ID_Num]), type nullable text},
{"ID_Issuer", each List.First([ID_Issuer]), type nullable text},
{"Ranking", each List.First([Ranking]), type nullable text}
}
),
addGroupColumn = Table.AddColumn(groupIdType, "GroupColumn", each "Group Me"),
groupGroupColumn = Table.Group(
addGroupColumn,
{"GroupColumn"},
{
{"ID_Type", each Text.Combine(List.Distinct([ID_Type]), ";"), type nullable text},
{"ID_Num", each Text.Combine(List.Distinct([ID_Num]), ";"), type nullable text},
{"ID_Issuer", each Text.Combine(List.Distinct([ID_Issuer]), ";"), type nullable text},
{"Ranking", each Text.Combine(List.Distinct([Ranking]), ";"), type nullable text}
}
)
in
groupGroupColumn
It changes this:
...to this:
Pete
Proud to be a Datanaut!
Hi @Anonymous ,
The following code should work for both scenarios. It uses two Group Bys to bundle up the [ID Type]s first, then to create the value lists:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8slMTs1LTlXSUTI0MjYxBdKOTs4gnlKsDrKsmbmFpQGQdnF1g8sGJBYXF+QXlQAFTEzNgGREZBSQNAJL+pdkpBYBecbGxkAysTg1HcRRio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID_Type = _t, ID_Num = _t, ID_Issuer = _t, Ranking = _t]),
groupIdType = Table.Group(
Source,
{"ID_Type"},
{
{"ID_Num", each List.First([ID_Num]), type nullable text},
{"ID_Issuer", each List.First([ID_Issuer]), type nullable text},
{"Ranking", each List.First([Ranking]), type nullable text}
}
),
addGroupColumn = Table.AddColumn(groupIdType, "GroupColumn", each "Group Me"),
groupGroupColumn = Table.Group(
addGroupColumn,
{"GroupColumn"},
{
{"ID_Type", each Text.Combine(List.Distinct([ID_Type]), ";"), type nullable text},
{"ID_Num", each Text.Combine(List.Distinct([ID_Num]), ";"), type nullable text},
{"ID_Issuer", each Text.Combine(List.Distinct([ID_Issuer]), ";"), type nullable text},
{"Ranking", each Text.Combine(List.Distinct([Ranking]), ";"), type nullable text}
}
)
in
groupGroupColumn
It changes this:
...to this:
Pete
Proud to be a Datanaut!
Thanks. that was quick.
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.