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
mhesli
New Member

Average and Median Time and filtering by another columns value

Good morning, 

 

                  I am trying to find the average and median time of a customer’s arrival to different points of their visit and have it filter the result to only include two types of visit reasons.

 

I am using the following formulas

Door to Purchase = 'Door to purchase'[Purchase date time]-'Door to purchase'[Customer arrival date time]

 

Door to Purchase in seconds = HOUR('Door to purchase'[Door to purchase])*3600+ MINUTE('Door to purchase'[Door to purchase])*60+SECOND('Door to purchase'[Door to purchase])*1)

 

Average Duration Arrival to Purchase hh:nn:ss = FORMAT(AVERAGE('Door to purchase'[Door to Purchase in seconds]), 'hh:nn:ss")

 

This gives me the average time duration but I need to further filter it by reason for purchase.

 

I have these columns available

CAL reason for purchase Birthday = CALCULATE(COUNTROWS('Door to purchase'), CONSTAINSSTRING('Door to purchase'[Reason], "Birthday"))

 

CAL reason for purchase Wedding = CALCULATE(COUNTROWS('Door to purchase'), CONSTAINSSTRING('Door to purchase'[Reason}, "Wedding"))

 

Reason for Purchase is Birthday or Wedding = 'Door to purchase [CAL reason for purchase Birthday] +'Door to purchase [CAL reason for purchase Wedding]

 

Question 1 How do I find the average times filtering only customers with a purchase reason of Birthday or Wedding?

Question 2 How do I find the Median times filtering only customers with a purchase reason of Birthday or Wedding?

 

Any help is appreciated!

 

 

 

 

 

 

 

 

 

 

 

6 REPLIES 6
v-shamiliv
Community Support
Community Support

Hi @mhesli 
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you

v-shamiliv
Community Support
Community Support

Hi @mhesli 
I wanted to check if you had the opportunity to review the information provided by @Sahir_Maharaj . Please feel free to contact us if you have any further questions. If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-shamiliv
Community Support
Community Support

Hi @mhesli 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

 

Sahir_Maharaj
Super User
Super User

Hello @mhesli,

 

Can you please try this approach:

 

  • Question 1
Door to Purchase (Seconds) =
DATEDIFF(
    'Door to purchase'[Customer arrival date time],
    'Door to purchase'[Purchase date time],
    SECOND
)
Avg Arrival to Purchase (Birthday/Wedding) =
CALCULATE (
    AVERAGE('Door to purchase'[Door to Purchase (Seconds)]),
    FILTER (
        'Door to purchase',
        CONTAINSSTRING('Door to purchase'[Reason], "Birthday")
        || CONTAINSSTRING('Door to purchase'[Reason], "Wedding")
    )
)

 

  • Question 2
Median Arrival to Purchase (Birthday/Wedding) =
MEDIANX (
    FILTER (
        'Door to purchase',
        CONTAINSSTRING('Door to purchase'[Reason], "Birthday")
        || CONTAINSSTRING('Door to purchase'[Reason], "Wedding")
    ),
    'Door to purchase'[Door to Purchase (Seconds)]
)

 

If possible, it would be great if you could you please provide sample data.

 

Many thanks.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
v-shamiliv
Community Support
Community Support

Hi @mhesli 
Thank you for reaching out microsoft fabric community forum.
As mentioned by @lbendlin Could you please provide sample data so that we can assist you more efficiently?.
Thankyou.

 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.