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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
MelisenDK
Frequent Visitor

Calculate weighed average

I want to make a measure that calculate a weighted average of how many minutes our customers have been actively shopping in our store but I can´t for the life of me figure out how to do this in DAX.

 

Say I have these two lines

 

minutesInStoreminutesQueueCustomers
30510
20105

 

I want to figure out how long time the average customer have spend in my store actively shopping (minutesInStore-minutesQueue)

 

My normal go-to in SQL would be to make a column calculating the total minutes per line (minutesInStore-minutesQueue)*Customers as customerMinutes)

 

minutesInStoreminutesQueueCustomerscustomerMinutes
30510250
2010550

 

and then the sum of customerMinutes divided by customers (sum(customerMinutes)/sum(customers) as avgMinutes

 

(250+50)/(10+5)=20

 

But how can I replicate that in DAX?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Avg Minutes =
VAR CustomerMinutes =
    SUMX (
        'Table',
        ( 'Table'[Minutes in store] - 'Table'[Minutes In Queue] ) * 'Table'[Customers]
    )
VAR Customers =
    SUM ( 'Table'[Customers] )
RETURN
    DIVIDE ( CustomerMinutes, Customers )

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @MelisenDK 

Thanks for reaching out to us.

I just want to confirm if you resolved this issue? If yes, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.

If you need more help, please let me know.

 

Best Regards,

Community Support Team _Tang

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

johnt75
Super User
Super User

Try

Avg Minutes =
VAR CustomerMinutes =
    SUMX (
        'Table',
        ( 'Table'[Minutes in store] - 'Table'[Minutes In Queue] ) * 'Table'[Customers]
    )
VAR Customers =
    SUM ( 'Table'[Customers] )
RETURN
    DIVIDE ( CustomerMinutes, Customers )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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