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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
naeljb
Helper I
Helper I

monthly average sales table from daily sales table

Hi Power Bi and DaX gurus,

 

I have a table with the daily sales of two products (table1).   How can I generate another table (table2) that gives me the monthly average sales for both product in a single table?  I used the “groupby”  DaX function but it generates a table with only one product.  Below is my table and the result table that I would like to get. Any tips or help on the DaX formula?

 

Table1

Date

Sales_A

Sales_B

5/15/2018

20

10

5/16/2018

30

20

6/15/2018

10

40

6/16/2018

20

20

 

Table2

 

Date

Average Sales_A

Average Sales_B

May 2018

50

15

June 2018

15

30

 

 

Thanks for your help 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

First, you need to add a calculated column to you first table:

 

Month = MONTH([Date])

Then, 

 

Table = SUMMARIZE('Table',[Month],"Average Sales_A",AVERAGE([Sales_A]),"Average Sales_B",AVERAGE([Sales_B]))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Sure it would, you just keep adding columns, you can add as many columns to summarize as you wish.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

First, you need to add a calculated column to you first table:

 

Month = MONTH([Date])

Then, 

 

Table = SUMMARIZE('Table',[Month],"Average Sales_A",AVERAGE([Sales_A]),"Average Sales_B",AVERAGE([Sales_B]))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank Greg.  It works perfectly.  

it seems that summarize would not work if I have more than 2 products

Sure it would, you just keep adding columns, you can add as many columns to summarize as you wish.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Yes, you are right.  it works with many column. Thank you very much.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.