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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors