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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
mumair
Helper I
Helper I

How to Group By?

How do I group my data? Let's say for example, I have data with these columns: managers, months, and sales. I want the total sales per month per manager. How would I write this in DAX?

1 ACCEPTED SOLUTION

Hi @mumair,

You can create a new table using SUMMARIZE function by New Table under Modeling on home page->type the following formula.

Group-by-table=SUMMARIZE(Table,Table[Month], Table[Managers],"Total Sales", sum(Table[sale]))  


You also can create a new calculated column using the formula.

Total-sales-column = CALCULATE(SUM(Table[sales]),ALLEXCEPT(Table,Table[Month],Table[Managersr]))


Thanks,
Angelia

View solution in original post

3 REPLIES 3
CahabaData
Memorable Member
Memorable Member

You may not need dax.  Try experimenting with a Table visual or a Matrix visual - drag the fields into the appropriate design wells in the design pane - - and for this type of data PBI is going to recognize that grouping & aggregation.

 

If you already know this - and know you need/want to model it with calculated measure/columns - provide just a few line/record samples of your raw data table as a starting point...

www.CahabaData.com

Yes, I need to use DAX. The example I provided was to assist me in my actual dataset which is much larger. I cannot share the real data because it is properitary.

 

 

Hi @mumair,

You can create a new table using SUMMARIZE function by New Table under Modeling on home page->type the following formula.

Group-by-table=SUMMARIZE(Table,Table[Month], Table[Managers],"Total Sales", sum(Table[sale]))  


You also can create a new calculated column using the formula.

Total-sales-column = CALCULATE(SUM(Table[sales]),ALLEXCEPT(Table,Table[Month],Table[Managersr]))


Thanks,
Angelia

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.