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.
Here are the corrected formulas. First, let's simplify your base measure for the individual average price. Then, we'll create the "All time" version that correctly ignores the date filters.
1. Average Price (Current Period)
This simple measure will correctly calculate the average price based on the current context (the specific year, month, customer, etc. selected in your visual).
Average Price =
DIVIDE(
SUM('Data'[Sales]),
SUM('Data'[Volume])
)
2. All-Time Average Price
This measure reuses the [Average Price] measure but modifies its context. It removes all filters from your Calendar table to get the true, all-time average.
All Time Average Price =
CALCULATE(
[Average Price],
ALL('Calendar')
)
By using this pattern, the [All Time Average Price] will remain constant across different time periods in your visual, allowing for a direct comparison, while still respecting filters from other tables (like Customers or Products).
If this explanation and solution resolve your issue, please like and accept the solution.