Power Pivot/DAX: Problem with Like for Like Sales Figure

Jubjab

Well-known Member
Joined
Jan 3, 2007
Messages
993
I am trying to build a DAX measure in a Power Pivot to show the Like for Like sales figure (LFL). LFL is simply a measure to show the sales if the customer also had sales during the same period last year.

I can not get any figures at all for this, and this is due to the previous year not working for some reason.

The formula I am trying to use is

=CALCULATE([Total Sales];FILTER(Data;[Total Sales]>0 && [Prev.year sales]>0))

This formula works but gives no data for any selection.

Just to test, I made formula just to show previous year's sales. Also this formula gives no values for any customers.

=CALCULATE([Prev.year Sales];FILTER(Data;[Prev.year Sales]<>0))

The formula [Prev.year Sales] looks like this, and does work as intended:

=CALCULATE([Total Sales];SAMEPERIODLASTYEAR('Calendar'[Date]))

Any ideas what is wrong? Thanks!
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,559
If you're interested in the customers that had sales last year as well as this year try filtering the customers table instead of your fact table. Something like
Code:
[COLOR=#333333][FONT=Consolas]Sales Change :=[/FONT][/COLOR]
[COLOR=#0070FF][FONT=Consolas]CALCULATE[/FONT][/COLOR][COLOR=#969696][FONT=Consolas] ([/FONT][/COLOR]
[COLOR=#333333][FONT=Consolas]    [/FONT][/COLOR][COLOR=#333333][FONT=Consolas][Total Sales] - [Sales LY];[/FONT][/COLOR]
[COLOR=#333333][FONT=Consolas]    [/FONT][/COLOR][COLOR=#0070FF][FONT=Consolas]FILTER[/FONT][/COLOR][COLOR=#969696][FONT=Consolas] ([/FONT][/COLOR][COLOR=#333333][FONT=Consolas] [/FONT][/COLOR][COLOR=#0070FF][FONT=Consolas]VALUES[/FONT][/COLOR][COLOR=#969696][FONT=Consolas] ([/FONT][/COLOR][COLOR=#333333][FONT=Consolas] Customers[Name] [/FONT][/COLOR][COLOR=#969696][FONT=Consolas])[/FONT][/COLOR][COLOR=#333333][FONT=Consolas]; [Total Sales] > [/FONT][/COLOR][COLOR=#EE7F18][FONT=Consolas]0[/FONT][/COLOR][COLOR=#333333][FONT=Consolas] && [Sales LY] > [/FONT][/COLOR][COLOR=#EE7F18][FONT=Consolas]0[/FONT][/COLOR][COLOR=#333333][FONT=Consolas] [/FONT][/COLOR][COLOR=#969696][FONT=Consolas])[/FONT][/COLOR]
[COLOR=#969696][FONT=Consolas])[/FONT][/COLOR]
should work.
 
Last edited:

Jubjab

Well-known Member
Joined
Jan 3, 2007
Messages
993
I'm not really following you here, sorry. To clarify.

I simply want my new measure to show the customer's sales, if it also has sales during the same period last year.

So

Customer Total Sales Prev.year Sales LikeForLike
A____________100_________ 50 _________100_____
B____________200_____________________________
C____________150_________225__________150____
D____________175 ________170 __________175____
E________________________500_________________


If I use the DAX formula

=CALCULATE([Total Sales];FILTER(Data;[Total Sales]>0))

I get the same values as the Total Sales (obviously). But if I make the same formula for last year, i.e.

=CALCULATE([Prev.year Sales];FILTER(Data;[Prev.year Sales]>0))

I get no values at all. Why is that?
 
Last edited:

Jubjab

Well-known Member
Joined
Jan 3, 2007
Messages
993
To further clarify, all needed data is residing in the Data table. It's a list of all sales, including the customer name. So for the purposes of this measure, I only need the data table and the calendar. I don't have a separate customer table.
 

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,559
Try:
LFL :=
CALCULATE (
[Total Sales];
FILTER ( VALUES ( Sales[Customer] ); [Total Sales] > 0 && [Sales LY] > 0 )
)
 

Forum statistics

Threads
1,089,449
Messages
5,408,297
Members
403,196
Latest member
annph

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top