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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Md_asgar
Frequent Visitor

How to do 3 layer group by

How to do the below in Powerbi:

First you group by three columns ID, desc and qty. second, from the output above, you group by ID and Desc, lastly by ID.


I have a table with the below columns:
ProdoNum: number of each product
ProdoCls: Product column number
ProdoDesc: Product description
Location: Location of the product delivery
ProdStat: Product state
UnitCost: Unit cost of each product
SalePrce: Selling price of the product
ReviewDT: Date on which product is reviewed
QuantityOH: quantity of the product send to each seller
InvValue: final bill send with the product

 

The below is the M-Code I have written, but in the final output I am not getting the more then 1,

can anyone please help me on this:
let
// Load your table here
Source = #"p_InventoryAllRegions",

// First group by ProdoNum, ProdoDesc, and QuantityOH
GroupedStep1 = Table.Group(
Source,
{"ProdoNum", "ProdoDesc", "QuantityOH"},
{{"Count of Records", each Table.RowCount(_), Int64.Type}}
),

// Second group by ProdoNum and ProdoDesc, aggregating the counts
GroupedStep2 = Table.Group(
GroupedStep1,
{"ProdoNum", "ProdoDesc"},
{{"Total QuantityOH Groups", each List.Sum([Count of Records]), Int64.Type}}
),

// Third group by ProdoNum, aggregating the counts again
GroupedStep3 = Table.Group(
GroupedStep2,
{"ProdoNum"},
{{"Total Product Groups", each List.Sum([Total QuantityOH Groups]), Int64.Type}}
)
in
GroupedStep3

2 REPLIES 2
amitchandak
Super User
Super User

@Md_asgar , The code seem fine.  Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

You can do this using a measure in visual

DAX Measure =

Sumx(Summarize(Table, Table[ProdoNum], Table[ProdoDesc], Table[QuantityOH], "_1", countrows(Table)),[_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak sure, below is the sample data link :

Sample data set 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.