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
RodrigoBreguel
Regular Visitor

Add rows to grouped data in power B

Hi everyone, I would be very thankful if someone could help me with an issue I am having with my data.

I have a database containing all the documents that an online education platform has on its website. I grouped the data according to the grade, the subject and the module (because the analysys has to be done at that level) using the GROUP BY function and then added another column with the number of documents at each level. I got something like this.

1.png

(the number at the lesft are just for me to explain, they represent each group)

 

My problem is that I want to show the number of documents of each type every group has ,no matter there are no document of some of the type. the document type can be: tests, videos, handbooks, notes and answer keys. 

Taking as an example the groups 1 and 2, I would like to get a table like the following:

2.png

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @RodrigoBreguel 

I can get the result as below:Capture7.JPG

To get this, please create a new query in transform data,

Capture8.JPG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKkktLilWitWJVirLTEnNhzAzEvNSkvLzsyG8vHygIjArMa+4PLVIITu1EsiPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Type = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Type", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(#"Changed Type"[Type],",")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Table[Index]),
    #"Expanded Custom.1" = Table.ExpandListColumn(#"Added Custom1", "Custom.1"),
    #"Removed Duplicates" = Table.Distinct(#"Expanded Custom.1", {"Custom.1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Removed Duplicates",{"Type"}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Removed Columns", {{"Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Custom", type text}})
in
    #"Changed Type1"

Then create relationships and measure

Capture9.JPG

Measure = var m=CALCULATE(SUM('Table'[Count]),FILTER('Table','Table'[Type]=MAX('Table 2'[Custom]))) return m

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @RodrigoBreguel 

I can get the result as below:Capture7.JPG

To get this, please create a new query in transform data,

Capture8.JPG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKkktLilWitWJVirLTEnNhzAzEvNSkvLzsyG8vHygIjArMa+4PLVIITu1EsiPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Type = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Type", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(#"Changed Type"[Type],",")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Table[Index]),
    #"Expanded Custom.1" = Table.ExpandListColumn(#"Added Custom1", "Custom.1"),
    #"Removed Duplicates" = Table.Distinct(#"Expanded Custom.1", {"Custom.1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Removed Duplicates",{"Type"}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Removed Columns", {{"Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Custom"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Custom", type text}})
in
    #"Changed Type1"

Then create relationships and measure

Capture9.JPG

Measure = var m=CALCULATE(SUM('Table'[Count]),FILTER('Table','Table'[Type]=MAX('Table 2'[Custom]))) return m

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-juanli-msft
Community Support
Community Support

Hi @RodrigoBreguel 

Would you mind me creating another table to achieve your requirement?

 

Best Regards

Maggie

what do you mean? the database I uploaded as a picture is just an example. Te real database is huge, so it is not possible to do it by hand.

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.