Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have the following DAX expression in a report that extracts the level 1 category name based on prefix-matching and a known hierarchy level:
Level_1 = VAR ThisCode = 'DimensionTable'[Code] RETURN CALCULATE ( MAX('DimensionTable'[Name]), FILTER ( 'DimensionTable', 'DimensionTable'[Level] = 1 && LEFT(ThisCode, LEN('DimensionTable'[Code])) = 'DimensionTable'[Code] ) )
I want to implement the same logic directly in Power Query as a custom column, using M language. The logic should:
Use the first characters of a code field
Match it against rows where Level = 1
Return the corresponding Name from that row
Could someone help me rewrite this logic correctly in Power Query?
You can try
= let
CurrentCode = [iec_code],
Name =
List.First(
Table.Column(
Table.SelectRows( #"Previous Step", each Text.StartsWith([iec_code], CurrentCode) and [level] = 1 ),
"name"
)
)
in
Name
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
77 | |
59 | |
36 | |
33 |
User | Count |
---|---|
100 | |
62 | |
56 | |
48 | |
41 |