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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PeterStuhr
Helper V
Helper V

Running total - exclude if no orders for months

Hi all,

 

I have a challenge I would need some help with.

 

My setup:

* Sales table containing "Company ID", "Order Date", "Revenue".

* Company table containing dimensions (Relation to Company ID)

* Date table (Relation to Order Date)

 

I would like to do a running total showing number of companies (customers we have), based on their first order.

However, if a customer suddenly has not bought for 18 months, they should not be included in the next months.

 

Example:

Company A buys first time 1st Jan 2015. They are counted every month ahead. Let's say their last order is 31 May 2015, then they should be counted from Jan 2015 until Nov 2016 (18 months since 31 May 2015). After that, they should not be counted anymore. It is important that they are STILL counted all months before the 18 months, but only not counted after that period. How would I do that?

 

I have tried with this: 

DateDiffMonths = DATEDIFF(TODAY(), [Last Date], MONTH)
 
However, that is looking in real time from TODAY always, which is not what I want. I want it to look "based on each month" if there was order 18 months back.
 
I hope it makes sense!
 
Thanks!

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@PeterStuhr ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hello,

 

Here I put an example of Companies and Order Date, and I added a column showing "CountUntil", meaning for how long this company (based on each order) should count in the rolling total companies. 

 

 

IDOrder DateLast Until
A01-01-201524-06-2016
A25-06-201516-12-2016
A12-12-201504-06-2017
A01-03-201623-08-2017
A05-08-201627-01-2018
A01-12-201625-05-2018
B01-01-201524-06-2016
B25-06-201516-12-2016
B12-12-201504-06-2017
B01-03-201623-08-2017
B05-08-201627-01-2018
B01-12-201625-05-2018
B01-01-201725-06-2018
B14-02-201708-08-2018
C01-06-201723-11-2018
C14-10-201707-04-2019
C17-07-201808-01-2020
C12-12-201904-06-2021



And here is my desired output:

 

 
 

Capture.JPG

 

Example: Company A has its first order Jan 2015, and its last order Dec 2016. It means it should count until May 2018 (Last Order + 18 months). 

 

How do I make this in PBI?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.