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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
gbarr12345
Post Prodigy
Post Prodigy

Number of Days between orders for a certain customer

Hi,

 

I'm trying to create a measure that will calculate the number of days or weeks between Sales for a certain customer.

 

I'm struggling to get a working measure so any help would be greatly appreciated.

 

I've the link to sample Power BI data attached here too for your reference.

 

Many Thanks in advance!

 

Power BI File - https://drive.google.com/file/d/19ATFPApHUaFITZ9Yg1XmRxhbCS2uxifV/view?usp=sharing

 

Excel link - https://docs.google.com/spreadsheets/d/1kjrOwCWgMqvXCaDTpyFc8iJavVb4jtRR/edit?usp=drive_link&ouid=11...

 

 

 

 

 

My Drive - Google Drive

14 REPLIES 14
lbendlin
Super User
Super User

First step would be to check and adjust your data model.

 

Market Table is not a dimension

Item Table and Customer Table need single direction

What's the purpose of the Period table?

 

lbendlin_0-1715554448310.png

 

Oh yes, I've updated this now thank you!

 

The period table was just a table created to put in the Financial Year etc but it's not being used here now.

 

The updated PBIX is here now - https://drive.google.com/file/d/19ATFPApHUaFITZ9Yg1XmRxhbCS2uxifV/view?usp=sharing

 

Excel - https://docs.google.com/spreadsheets/d/1FX1T2MmY7xv7rjvdH3IwahiqXupxjD3Y/edit?usp=drive_link&ouid=11...

 

Hey, is there any solution you have been able to see from my data by any chance?

 

I've tried a few DAX measures but to no luck...

Why is Canada twice in your Market table?

 

lbendlin_0-1715634259680.png

 

Apologies, that was put in twice in error. I can remove it now and let you know once removed.

Here's a more appropriate version of the data model

 

lbendlin_0-1715634992779.png

 

But you can also opt not to connect the Calendar table.

lbendlin_1-1715635034317.png

 

Now your question  is 

calculate the number of days or weeks between Sales for a certain customer

That would require multiple transactions per customer.  Your sample data only lists each customer with a single transaction.

lbendlin_2-1715635188521.png

 

Please use the attached to improve your sample data.

 

In case of more than two transactions per customer do you want to see the individual differences, an average, or something else?

 

 

I've followed your tips now and the differences seem a good bit off:

 

gbarr12345_0-1715636664601.png

 

 

Some customers have more than 2 transactions as per the screenshot attached. I want to see the difference between each date for the customers. I have the customers in a slicer so only need to see the days between each transaction date.

 

 

I want to see the difference between each date for the customers.

How would that look like in a report?  I cannot visualize it.

This is how it would look:

 

gbarr12345_0-1715639536374.png

 

Where did the 130 come from?

I'm not sure where the 130 came from...

 

The other figures were correct though.

please modify the sample PBIX to include a couple of customers with multiple transactions.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors