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
Anonymous
Not applicable

Excel SUMPRODUCT formula in DAX or PowerQuery (M)

Hello, 

 

I have a report in excel that has a column with a sumproduct formula to calculate the count the number of times remaining a person's name shows up in a specific department.  

 

Example data is below with a desired output column.

 Department Full Path Job
Name (1)
Default LocationPay TypeFull NameDesired Output
Tooling - Fixtures2020 Direct Labor JobsProductionNon-ExemptPerson 41
Tooling - Fixtures2020 Direct Labor JobsProductionNon-ExemptPerson 51
Tooling - Fixtures2020 Direct Labor JobsProductionNon-ExemptPerson 13
Tooling - Fixtures2020 Direct Labor JobsProductionNon-ExemptPerson 31
Tooling - FixturesIndirect LaborProductionNon-ExemptPerson 12
Tooling - FixturesDirect Labor JobsProductionNon-ExemptPerson 11
Tooling - FormIndirect LaborProductionNon-ExemptPerson 13
Tooling - Form2020 Direct Labor JobsProductionNon-ExemptPerson 31
Tooling - Form2020 Direct Labor JobsProductionNon-ExemptPerson 12
Tooling - Form2020 Direct Labor JobsProductionNon-ExemptPerson 61

The SUMPRODUCT formula used is =SUMPRODUCT((E2:$E$10001=E2)*(A2:$A$10001=A2)).

 

Person 1 is the best example of what I would like to achieve, either as a custom column in PQ or as a measure in DAX.  You can see Person 1 starts off as a count of 3 as there are 3 person 1's in Tooling - Fixtures.  This number then decreases 2, 1 as the next records containing person 1 are found in the Tooling - Fixtures department. 

 

After reading forums on here I messed around with SUMX however, I could not achieve the desired output. 

 

I greatly appreciate any help.

Thanks,

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please check:

Column =
CALCULATE (
    COUNT ( 'Table'[Full Name] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Department Full Path], 'Table'[Full Name] ),
        'Table'[Index] >= EARLIER ( 'Table'[Index] )
    )
)

column.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please check:

Column =
CALCULATE (
    COUNT ( 'Table'[Full Name] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[Department Full Path], 'Table'[Full Name] ),
        'Table'[Index] >= EARLIER ( 'Table'[Index] )
    )
)

column.PNG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Anonymous - See this article:

https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991

 

Which will then take you to here:

https://community.powerbi.com/t5/Community-Blog/S-Excel-to-DAX-Translation/ba-p/1061121

 

Which provides this equivalent:

SUMPRODUCT = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table1',
            "Value",[Value1] * RELATED(Table2[Value2])
        )
RETURN
    SUMX(__Table,[Value])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.