Hello there,
I am calculating total sales. sounds simple. but filters that i need in sales amount is 1) Sales YTD 2) based on sales type selection 4) and based on store category selection. This seems to be working file. But is there a simpler way to achieve the result.
Total Sales =
VAR CurrentYear = [Sales Year]
VAR StoreTypeSelection =
IF (
HASONEVALUE ( 'store comparison flag'[Select Measure] ),
SELECTEDVALUE ( 'store comparison flag'[Select Measure] ),
"All"
)
VAR SalesTypeSelection =
IF (
HASONEVALUE ( 'sales type'[Sales Type] ),
SELECTEDVALUE ( 'sales type'[Sales Type] ),
"All"
)
VAR TotalAmount =
CALCULATE (
IF (
ISFILTERED ( 'sales type'[Sales Type] ),
CALCULATE (
SUM ( 'sales'[Sales Amount] ),
FILTER ( 'sales', 'sales'[Sale Type] = SalesTypeSelection )
),
CALCULATE ( SUM ( 'sales'[Sales Amount] ) )
),
FILTER ( 'calendar', 'calendar'[Sales Year] = CurrentYear )
)
RETURN
IF (
ISFILTERED ( 'store comparison flag'[Select Measure] ),
CALCULATE (
CALCULATE (
IF (
ISFILTERED ( 'sales type'[Sales Type] ),
CALCULATE (
SUM ( 'sales'[Sales Amount] ),
FILTER ( 'sales', 'sales'[Sale Type] = SalesTypeSelection )
),
CALCULATE ( SUM ( 'sales'[Sales Amount] ) )
),
FILTER ( 'calendar', 'calendar'[Sales Year] = CurrentYear )
),
FILTER (
stores,
COUNTROWS (
FILTER (
'store comparison flag',
stores[Stores Comparision Flag] = StoreTypeSelection
)
)
)
),
TotalAmount
)