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
dpombal
Post Patron
Post Patron

weighted average / sum product in DAX fix grand totals

 

Hi all,

I have a table with 32 processes (rows) having 2 different status ( denied and accepted),

 

There are 2 direct measures ( sum_days_of duration and number of processes)

 

1_table_Data.PNG

 

My question is about calculating the average of duration days weighted in the following way ( My measure fails on calculating totals, see below pbix)

 

 

sum product average.PNG

 

Here it is my current pbix (download link here)

 

sum_of_days = sum(Data[days])

 

Count_Of_Processes = DISTINCTCOUNT(Data[IdProcess])

 

Avg_Days = DIVIDE([sum_of_days];[Count_Of_Processes]) --> Fails on totals for my usecase i need a weighted like before sumproduct formulae

 

3_weighted_Average_pbix.PNG

 

 

I am lookinf for 16,99 in totals instead of 3,41

Thanks in advance

 

2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

Hi @dpombal

 

Try this revision

 

Avg_Days =
IF (
    HASONEVALUE ( Data[Status] ),
    DIVIDE ( [sum_of_days], [Count_Of_Processes] ),
    DIVIDE (
        SUMX ( ALL ( Data[Status] ), [sum_of_days] * [Count_Of_Processes] ),
        SUM ( Data[days] )
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @dpombal

 

Try this revision

 

Avg_Days =
IF (
    HASONEVALUE ( Data[Status] ),
    DIVIDE ( [sum_of_days], [Count_Of_Processes] ),
    DIVIDE (
        SUMX ( ALL ( Data[Status] ), [sum_of_days] * [Count_Of_Processes] ),
        SUM ( Data[days] )
    )
)

Regards
Zubair

Please try my custom visuals

@dpombal

 

sumproduct.png


Regards
Zubair

Please try my custom visuals

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.