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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
zahrabajgiran
Regular Visitor

using average and SUM

INVOICESTEPINVOICEDATETASKENDTIMEDAYSSPENT
22093CProcess Invoice2022-04-2941:00.05
22093CSuper Approval2022-04-2914:00.037
22093CGL Stamp Job/Subcontractor2022-04-2941:00.00
22093CFinal Approval2022-04-2941:00.00
22093CPM Approval2022-04-2921:00.00
22093CVP Approval2022-04-2922:00.00
22093CInvoice Coder Not Found2022-04-2910:00.00
22113HBProcess Invoice2022-05-1752:00.093
22113HBVP Approval2022-05-1731:00.07
22113HBSuper Approval2022-05-1748:00.028
22113HBFinal Approval2022-05-1709:00.00
22113HBGL Stamp Job/Subcontractor2022-05-1753:00.00
22113HBPM Approval2022-05-1755:00.028

 

Hello everybody, 

I am new to DAX and I searched a lot for my question but I was not successful to get an answer. 

I put my table here. 

I want to have a new coloumn which shows me the SUM of DAYSSPENT on unique INVOICE numbers, and then I want to be able to have an AVERAGE of those SUM.

1 ACCEPTED SOLUTION
barritown
Super User
Super User

Hi @zahrabajgiran,

barritown_0-1685710521742.png

If the columns on the screenshot above match your expectations, you can achieve such results using two similar calculated columns:

SUM_DAYSSPENT = 
VAR CurrentInvoice = [INVOICE]
RETURN SUMX ( FILTER ( ALL(data), [INVOICE] = CurrentInvoice ), [DAYSSPENT] )

AVG_DAYSSPENT = 
VAR CurrentInvoice = [INVOICE]
RETURN AVERAGEX ( FILTER ( ALL(data), [INVOICE] = CurrentInvoice ), [DAYSSPENT] )

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

View solution in original post

1 REPLY 1
barritown
Super User
Super User

Hi @zahrabajgiran,

barritown_0-1685710521742.png

If the columns on the screenshot above match your expectations, you can achieve such results using two similar calculated columns:

SUM_DAYSSPENT = 
VAR CurrentInvoice = [INVOICE]
RETURN SUMX ( FILTER ( ALL(data), [INVOICE] = CurrentInvoice ), [DAYSSPENT] )

AVG_DAYSSPENT = 
VAR CurrentInvoice = [INVOICE]
RETURN AVERAGEX ( FILTER ( ALL(data), [INVOICE] = CurrentInvoice ), [DAYSSPENT] )

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.