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
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
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.

Top Solution Authors