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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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