Forum Discussion
Removing date filter
- Anonymous1 year ago
Hi tfr111 ,
Thank you for confirming the earlier results. The current calculation only iterates at the customer level, which leads to discrepancies in monthly subtotals when dates are shown in the visual. To resolve this, update the measure to iterate over both the date and customer context using the SUMMARIZE() function. This will ensure that monthly subtotals match the sum of customer rows, yearly totals add up correctly, and the all-time average price stays consistent across all date levels. Use the following DAX:
New Mix Sales (Correct Dates) = VAR _fixedAvgPrice = CALCULATE( DIVIDE(SUM('Data'[Sales]), SUM('Data'[Volume])), REMOVEFILTERS('Date') ) RETURN SUMX( SUMMARIZE( 'Data', 'Date'[Year], 'Date'[Month Number], 'Data'[Reporting Customer] ), _fixedAvgPrice * CALCULATE(SUM('Data'[Volume])) )I hope this will resolve your issue, if you need any further assistance, feel free to reach out.
Thank you.
Hi there,
Is your 'Data'[Date] in an actual Date table that filters your fact table? It does not look like so to me as your Sales and Volumes colums are all in this table.
If they are all in the fact table, ALL('Data'[Date]) only removes filters from the Date column inside the fact table, not the filters from the external Date table.
Assuming your model has a Date table called 'Date' that is related to 'Data' (if there is not, you would need to build one for the purpose of better performance) you should write:
AllTimeAvgPrice =
DIVIDE(
CALCULATE(
SUM('Data'[Sales]),
ALL('Date')
),
CALCULATE(
SUM('Data'[Volume]),
ALL('Date')
)
)
If you only has this one table in the model and you are not planning to make any model change, you may try with ALL('Data') as your filter modifier instead of ALL('Data'[Date])
Hope it helps:)