cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Helper V

## Volume lost for 12 months prior to customer loss

@speedramps

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.

1 ACCEPTED SOLUTION
Community Support

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.

10 REPLIES 10
Community Support

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.

Helper V

@v-tangjie-msft

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

Helper V

@v-tangjir-msft

Hi Neeko, this worked perfectly.  Thank you for helping me.

Bud

Helper V

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.

Super User

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

Helper V
Helper V

@speedramps

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

Helper V

My apologies,  I tested the link several time and it worked fine.  I will get  one that works.

Super User

Hi Bud

I will try take a look tomorrow.

I am unpaid volunteer but like to help

Helper V

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

Announcements

#### Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors