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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
marcss44
Helper I
Helper I

Average Over Sum by date

I've got a table with multiple rows by invoices, overyone with invoice quantity and invoice date.

I need to sum invoice quantity by date to get something like this:

marcss44_0-1741253488500.png

And after that get an unique value of the average of every row.

How can i do it?

1 ACCEPTED SOLUTION

@marcss44 , Try using

dax
SumInvoiceQuantity =
SUMX(
SUMMARIZE(
Table1,
Table1[Fecha],
"TotalQuantity", SUM(Table1[Cantidad])
),
[TotalQuantity]
)

 

 

If this still doesn't work, you can try breaking it down into two separate measures to make it easier to debug:

Create a measure to calculate the total quantity per date:

dax
TotalQuantityPerDate =
SUMMARIZE(
Table1,
Table1[Fecha],
"TotalQuantity", SUM(Table1[Cantidad])
)

 

 

And one more for 

dax
SumInvoiceQuantity =
SUMX(
TotalQuantityPerDate,
[TotalQuantity]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

4 REPLIES 4
bhanu_gautam
Super User
Super User

@marcss44 Create a new measure in Power BI to sum the invoice quantity by date. You can use the SUM function along with GROUP BY to achieve this.

 

DAX
SumInvoiceQuantity =
SUMX(
SUMMARIZE(
'YourTable',
'YourTable'[InvoiceDate],
"TotalQuantity", SUM('YourTable'[InvoiceQuantity])
),
[TotalQuantity]
)

 

Create another measure to calculate the average of the summed quantities.

DAX
AverageOfSumInvoiceQuantity =
AVERAGEX(
SUMMARIZE(
'YourTable',
'YourTable'[InvoiceDate],
"TotalQuantity", SUM('YourTable'[InvoiceQuantity])
),
[TotalQuantity]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






I've used for this for the first part:

SumInvoiceQuantity =
 
SUMX(
SUMMARIZE(
Table1,
Table1[Fecha],
"TotalQuantity", SUM(Table1[Cantidad])
),
[TotalQuantity]
)
 
And it shows: the expression specified in the query is not a valid table expression

@marcss44 , Try using

dax
SumInvoiceQuantity =
SUMX(
SUMMARIZE(
Table1,
Table1[Fecha],
"TotalQuantity", SUM(Table1[Cantidad])
),
[TotalQuantity]
)

 

 

If this still doesn't work, you can try breaking it down into two separate measures to make it easier to debug:

Create a measure to calculate the total quantity per date:

dax
TotalQuantityPerDate =
SUMMARIZE(
Table1,
Table1[Fecha],
"TotalQuantity", SUM(Table1[Cantidad])
)

 

 

And one more for 

dax
SumInvoiceQuantity =
SUMX(
TotalQuantityPerDate,
[TotalQuantity]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Akash_Varuna
Solution Sage
Solution Sage

Hi @marcss44 Try these please 

  • Create a Date-Sum Table:

    • Use SUMMARIZE to group by date and sum the invoice quantities.

 

SumByDate = 
SUMMARIZE(
    'Table',
    'Table'[Date],
    "TotalQuantity", SUM('Table'[Quantity])
)​

 

  • Calculate the Average of Sums:

     

 

AverageSumByDate = 
AVERAGEX(
    SUMMARIZE(
        'Table',
        'Table'[Date],
        "TotalQuantity", SUM('Table'[Quantity])
    ),
    [TotalQuantity]
)

 

If this post helped please do give a kudos and accept this as a solution
Thanks In Advance

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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