Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
I am trying to determine the number of Gallons Lost during the 12-month period, prior to the End Date of the Account.
There are three tables provided in the data. A link to the data is provided.
Here is the Customer table. The End Date is the date a customer is lost.
Each customer has deliveries of fuel that are measured in Gallons. Some of the deliveries fall within the 12 months prior to the end date and some do not. I need only the gallons that do fall within that time period.
Here is the Sales Table
Also included in the data is a Calendar table ranging from 1/1/2022 to 12/31/2024.
One complication with the Calendar Table is that it is used for both the End Date of the customer and elsewhere in the report, for the customer Start Date.
In conclusion, I need the sum of Gallons Lost for the 12 months prior to the customer’s End Date.
Here is the link to an Excel spreadsheet containing the data tables.
https://1drv.ms/x/s!An-c-kQsqoNPglOF0ahWAx-kJHQh?e=uqaV1Q
Solved! Go to Solution.
Hi @BudMan512 ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a calculated column on Customer table.
Gallons lost =
VAR _date =
EDATE ( [End Date], -12 )
RETURN
CALCULATE (
SUM ( 'Sales'[Gallons] ),
FILTER (
'Sales',
Sales[Account] = EARLIER ( 'Customer'[Account] )
&& 'Sales'[Delivery Date] >= _date
&& 'Sales'[Delivery Date] <= EARLIER ( 'Customer'[End Date] )
)
)
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @BudMan512 ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a calculated column on Customer table.
Gallons lost =
VAR _date =
EDATE ( [End Date], -12 )
RETURN
CALCULATE (
SUM ( 'Sales'[Gallons] ),
FILTER (
'Sales',
Sales[Account] = EARLIER ( 'Customer'[Account] )
&& 'Sales'[Delivery Date] >= _date
&& 'Sales'[Delivery Date] <= EARLIER ( 'Customer'[End Date] )
)
)
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Neeko,
I have run into a snag with the provided formula. Results are wrong when there are 2 or more customers with the same end date and the values are duplicated. Below is a screenshot of the problem.
I wonder if you would mind taking a look at this?
Thanks,
Bud
@v-tangjir-msft
Hi Neeko, this worked perfectly. Thank you for helping me.
Bud
Thank you Neeko, I appreciate your help. I may not be able to try this until tomorrow but I would be happy to mark it as complete. It looks good, thank you.
We want to help you but you keep posting links that do not work.
Please ask friend, collegaue or manager to help show you how to share example data exeternally via OneDrive, Dropbox or Sharepoint.
It just wastes your time and our time if you keep sharing broken links. Thank you
As I did not hear back from you on this I assume yet another data link bit the dust.
Even though I couldn't give you the solution on this, I did learn a lot from you about the process, so thank you for that.
Bud
My apologies, I tested the link several time and it worked fine. I will get one that works.
Hi Bud
I will try take a look tomorrow.
I am unpaid volunteer but like to help
Someone else has provided the Solution to my question.
Thank you for the time you invested to help me better understand the process.
I do appreciate it.
Bud
User | Count |
---|---|
21 | |
20 | |
15 | |
10 | |
7 |
User | Count |
---|---|
28 | |
28 | |
13 | |
12 | |
12 |