Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
RichardT_78
Helper I
Helper I

Filting

Shop1 has 2 areas A or B so i need to be able to create a messure to seperate this 

areaCode shop 1shop 2shop 3
A3111  
B3111  
A311111
B234 1 
A1121 1
B1121  

 

Epected results 

 

A311Shop 1 2
B311Shop 1 1
A112Shop 1 1
B112Shop 1 1
B311shop 21
B234shop 21
B311shop31
A112shop31


How can you filter shop1 based on the A&B column ? 

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI2NASSIKwAxrE60UpOOMRR1UMwTL2RsQlUrSGKekNDIyRzEOpRxYHqYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [area = _t, #"Code " = _t, #"shop 1" = _t, #"shop 2" = _t, #"shop 3" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"area", type text}, {"Code ", Int64.Type}, {"shop 1", Int64.Type}, {"shop 2", Int64.Type}, {"shop 3", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"area", "Code "}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"area", "Code ", "Attribute"}, {{"Count", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

ppm1_0-1674922569053.png

 

FYI that, if you don't want to group the rows to create the count column, you can delete that step in the query and generate same result with a simple measure (in case you need to do other analyses).

 

Pat

Microsoft Employee

View solution in original post

2 REPLIES 2
RichardT_78
Helper I
Helper I

Thank you for your help Pat 

ppm1
Solution Sage
Solution Sage

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTI2NASSIKwAxrE60UpOOMRR1UMwTL2RsQlUrSGKekNDIyRzEOpRxYHqYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [area = _t, #"Code " = _t, #"shop 1" = _t, #"shop 2" = _t, #"shop 3" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"area", type text}, {"Code ", Int64.Type}, {"shop 1", Int64.Type}, {"shop 2", Int64.Type}, {"shop 3", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"area", "Code "}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"area", "Code ", "Attribute"}, {{"Count", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

ppm1_0-1674922569053.png

 

FYI that, if you don't want to group the rows to create the count column, you can delete that step in the query and generate same result with a simple measure (in case you need to do other analyses).

 

Pat

Microsoft Employee

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors