Calculating Lost Sales using Time Intelligence Functions

AJ1969

New Member
Joined
Sep 18, 2012
Messages
2
I have created a simple data model consisting of three tables: Customers, Calendar and Sales. I have a DAX measure that calculates lost customers, which I have defined as customers who did not ship in the current year (Year is in Row area of pivottable) and shipped in the prior year. It is:

Calculate(
COUNTROWS(Customers),
Filter(Customers,
Calculate(CountRows(Sales)) = 0
&&
Calculate(
CountRows(Sales), PARALLELPERIOD(
Calendar[Date],-1,Year))>0
)
)

I created this formula after viewing a video on ProjectBoticelli.com where Alberto Ferrari explained how to calculate new customers with this formula (his definition of a new customer is someone who shipped in the period being evaluated and did not ship in any previous period. His formula is:

Calculate(
CountRows(Customers),
Filter(
Customers,
Calculate(CountRows(Sales)) > 0 &&
Calculate (
CountRows(Sales),
Filter(
All(Calendar),
Calendar[FullDate] < Min(Calendar[FullDate])
)
) = 0
)
)


The first formula above appears to be returning the correct results but I would like to know if my syntax is correct.

Next I have tried to write another formula that calculates the lost sales, that is the sales made in the previous year to these lost customers. It is:

Calculate(
COUNTROWS(Sales),
Filter(Customers,
Calculate(
CountRows(Sales), PARALLELPERIOD(
Calendar[Date],-1,Year))>0
&&
Calculate(CountRows(Sales)) = 0

)
)

This formula is not returning any results and I admit that I'm not really sure what I am doing. It seems like I have to CountRows(Sales) but the Filter(Customers) doesn't make any sense to me.

Can someone please tell me whether or not my first formula is correct, and how to write the lost sales measure.

Regards

AJ1969
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
"The first formula above appears to be returning the correct results but I would like to know if my syntax is correct."

Well, if the syntax was not correct, PowerPivot would throw an error. :-)

Commenting on whether your formula does what it is supposed to do would require more information about the requirements.

Regarding the second formula:
Calculate(CountRows(Sales)) = 0

You filter customers who had no sales within the current filter context. Consequently, COUNTROWS(Sales) for these customers will return BLANK.
 
Upvote 0

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,646
Latest member
tudou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top