Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello Team,
I’ve successfully created a measure to calculate the Top N brands by sales and the "Others" category based on a Top N slicer. However, I've encountered an issue: when I add another column, such as "Year," to the matrix visual, the Top N brands vary across different years. I need the Top N brands to remain consistent across all years, regardless of the year filter.
@azadthakur , To ensure that the Top N brands remain consistent across all years, you need to modify your DAX measure to calculate the Top N brands without considering the year filter. This can be achieved by using the ALL function
Top N Retail Sales or Units =
VAR TopNValue1 = SELECTEDVALUE('TopN'[TopN])
VAR SalesorUnits = SELECTEDVALUE('Retail Sales or Units'[Metric])
-- Calculate the Top N brands without considering the year filter
VAR TopBrand =
TOPN(
TopNValue1,
ALL(TopNBrands),
SWITCH (
SalesorUnits,
"Units", [Sum of Units],
"Sales", [Sum of Sales],
BLANK ()
)
)
-- Calculate the total sales or units for all brands without considering the year filter
VAR AllRetailSalesUnits =
CALCULATE(
SWITCH (
SalesorUnits,
"Units", [Sum of Units],
"Sales", [Sum of Sales],
BLANK ()
),
ALL(TopNBrands)
)
-- Calculate the sales or units for the "Other" category
VAR OtherRetailSalesUnits =
AllRetailSalesUnits -
CALCULATE(
SWITCH (
SalesorUnits,
"Units", [Sum of Units],
"Sales", [Sum of Sales],
BLANK ()
),
TopBrand
)
-- Calculate the sales or units for the Top N brands
VAR TopNRetailsSalesUnits =
CALCULATE(
SWITCH (
SalesorUnits,
"Units", [Sum of Units],
"Sales", [Sum of Sales],
BLANK ()
),
KEEPFILTERS(TopBrand)
)
-- Get the current brand
VAR CurrentBrand = SELECTEDVALUE(TopNBrands[Brand])
RETURN
IF(
CurrentBrand = "Other",
OtherRetailSalesUnits,
TopNRetailsSalesUnits
)
Proud to be a Super User! |
|
Hi @bhanu_gautam , thanks for replying on this. My fiscal year column is in different table. I tried your formula but result is same the topn brands is different for each year.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 10 | |
| 10 | |
| 8 | |
| 6 | |
| 6 |
| User | Count |
|---|---|
| 24 | |
| 19 | |
| 19 | |
| 15 | |
| 9 |