I am working on getting the amount of new sales and lost sales with regards to sales previous year and sales year to date. I am trying to show this in a table and then filtering that table with a year slicer. Below are the formulas that i have used:
SalesPY = CALCULATE(SUM(SalesData[Value]),SAMEPERIODLASTYEAR('Calendar'[DateKey]))
SalesYTD = TOTALYTD(SUM(SalesData[Value]), 'Calendar'[DateKey])
NewSalesUppdate = SUMX(VALUES(SalesData[CustomerName]),IF([SalesYTD] > 0 && [SalesPY] = 0, [SalesYTD]))
LostSalesUppdate = SUMX(VALUES(SalesData[CustomerName]),IF([SalesYTD] = 0 && [SalesPY] > 0, -[SalesPY]))
LostSalesOld = IF([SalesPY] > 0 && [SalesYTD] = 0, -[SalesPY])
The NewSalesUppdate
formula works as it should and sums up correctly. However LostSalesUppdate
does not work, despite having pretty much the opposite formula compared with NewSalesUppdate
. It seems like the IF
statement never becomes true. That is strange because the LostSalesOld
formula shows the right value, but it does not show the total.
All tips are appreciated!
Sample Data:
Current Result:
Notice how customer A had no YTD sales. The LostSalesOld shows -85000 in sales, but nothing is reflected in the total. The LostSalesUppdate shows nothing at all.
Desired Result:
Now one of the lost sales columns (doesn't matter which) has a value for customer A, and a total