Forum Discussion
Power BI – YoY Measure Ignoring Product Filter but Respecting Slicers
- 8 months ago
have you tried all[product]?
YoY % Change=
VAR CurrentSales = CALCULATE([Total Sales], ALL('Product'))
VAR LastYearSales = CALCULATE([Total Sales], ALL('Product'), SAMEPERIODLASTYEAR('Date'[Date]))
RETURN
DIVIDE(CurrentSales - LastYearSales, LastYearSales)if this does not work, pls provide some sample data and expected output.
- 8 months ago
Hi SavioFerraz
If by product fitlers you mean all product-related filters and not simply product name or category, there must be sepaerate dimension table for this and in a measure you use either REMOVEFILTERS or ALL
In the image below, REMOVEFILTERS is applied to the Category table so the third measure returns the same previous year value for all categories. The columns from Category table must be used in the visual for this to work and not the fact column used in a relationship
- 8 months ago
YoY % =
VAR CurrentValue = [Sales]
VAR PriorYearValue =
CALCULATE(
[Sales],
SAMEPERIODLASTYEAR(Date[Date]),
REMOVEFILTERS(Product)
)
RETURN
DIVIDE(CurrentValue - PriorYearValue, PriorYearValue)If this answer helped, please click Kudos or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande - 8 months ago
YoY % (Ignore Product) = VAR SalesCY = CALCULATE ( [Sales], REMOVEFILTERS ( 'Product' ) ) VAR SalesPY = CALCULATE ( [Sales PY], -- e.g. CALCULATE([Sales], SAMEPERIODLASTYEAR('Calendar'[Date])) REMOVEFILTERS ( 'Product' ) ) RETURN DIVIDE ( SalesCY - SalesPY, SalesPY )That keeps Date and Region slicers working (because you’re not touching those tables), but any filter coming from Product (slicer, row/column headers, cross-highlighting) is ignored.
- 8 months ago
Oi Savio, espero que isso te ajude...
If this helped you, please give me some kudos! 👍 It motivates me to keep sharing solutions with the community.Sales Ignoring Product
Sales (Ignore Product) :=
CALCULATE (
[Sales],
REMOVEFILTERS ( DimProduct ) -- ou ALL ( DimProduct )
)Previous Year Sales (Still Ignoring Product)Sales LY (Ignore Product) :=
CALCULATE (
[Sales (Ignore Product)],
DATEADD ( DimDate[Date], -1, YEAR )
)If your calendar is not continuous or has gaps, you can replace with SAMEPERIODLASTYEAR ( DimDate[Date] ).
YoY % Change (Ignoring Product, Respecting Date/Region)
YoY % (Ignore Product) :=
VAR Curr = [Sales (Ignore Product)]
VAR Prev = [Sales LY (Ignore Product)]
RETURN
DIVIDE ( Curr - Prev, Prev )
``If you have more than one product-related table (e.g., category/brand), clear them all:CALCULATE ( [Sales], REMOVEFILTERS ( DimProduct, DimBrand, DimCategory ) )Power BI – YoY Measure Ignoring Product Filter (But Respecting Date & Region)Sales :=
SUM ( Sales[Amount] )
Sales (Ignore Product) :=
CALCULATE (
[Sales],
REMOVEFILTERS ( DimProduct )
)
Sales LY (Ignore Product) :=
CALCULATE (
[Sales (Ignore Product)],
DATEADD ( DimDate[Date], -1, YEAR )
)
YoY % (Ignore Product) :=
VAR Curr = [Sales (Ignore Product)]
VAR Prev = [Sales LY (Ignore Product)]
RETURN
DIVIDE ( Curr - Prev, Prev )Note: This text was translated using AI for better understanding by the forum and community.
- 8 months ago
Hi SavioFerraz ,
Please try the bellow measure and let me know if help you.
NOTE: change the table and column names with your ownYoY % Change = VAR CurrentYearSales = CALCULATE( SUM(Sales[Amount]), ALL(Products) ) VAR PreviousYearSales = CALCULATE( SUM(Sales[Amount]), ALL(Products), DATEADD(Dates[Date], -1, YEAR) ) VAR YoYChange = DIVIDE( CurrentYearSales - PreviousYearSales, PreviousYearSales ) RETURN YoYChange
Oi Savio, espero que isso te ajude...
Sales Ignoring Product
Sales (Ignore Product) :=
CALCULATE (
[Sales],
REMOVEFILTERS ( DimProduct ) -- ou ALL ( DimProduct )
)
Sales LY (Ignore Product) :=
CALCULATE (
[Sales (Ignore Product)],
DATEADD ( DimDate[Date], -1, YEAR )
)If your calendar is not continuous or has gaps, you can replace with SAMEPERIODLASTYEAR ( DimDate[Date] ).
YoY % Change (Ignoring Product, Respecting Date/Region)
YoY % (Ignore Product) :=
VAR Curr = [Sales (Ignore Product)]
VAR Prev = [Sales LY (Ignore Product)]
RETURN
DIVIDE ( Curr - Prev, Prev )
``
CALCULATE ( [Sales], REMOVEFILTERS ( DimProduct, DimBrand, DimCategory ) )
Sales :=
SUM ( Sales[Amount] )
Sales (Ignore Product) :=
CALCULATE (
[Sales],
REMOVEFILTERS ( DimProduct )
)
Sales LY (Ignore Product) :=
CALCULATE (
[Sales (Ignore Product)],
DATEADD ( DimDate[Date], -1, YEAR )
)
YoY % (Ignore Product) :=
VAR Curr = [Sales (Ignore Product)]
VAR Prev = [Sales LY (Ignore Product)]
RETURN
DIVIDE ( Curr - Prev, Prev )