Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
armvime
New Member

Dax Filter 3 criteria

Hello, I need help with a DAX measurement.
I have my measure called "Gross Margin" which calculates the gross margin I make on a number of products sold in various supermarkets. This measure comes created as the sum of other measures (turnover per product minus transport cost, minus distribution cost, etc).
The supermarkets are Carrefour, Mercadona and Dia and come from the column Master[Supermarkets].
The products I analyze are Milk, Eggs and Meat and come from the column Master[Products].
The cities I analyze are Madrid, Barcelona and Valencia and come from the column Master[City].
I need to create a new measure, called "Gross Margin Carrefour" that always gives me the Carrefour margin for that product, that city and to be able to compare it with other supermarkets.
So I need this:

 

  CarrefourCarrefourMercadonaMercadonaDíaDía
  Gross Margin CarrefourGross MarginGross Margin CarrefourGross MarginGross Margin CarrefourGross Margin
MadridEggs1001001009810055
Milk1201201203712024
Meat1301301304313089
BarcelonaEggs1021021029910232
Milk1221221222212256
Meat1321321325013278
ValenciaEggs979797969735
Milk1171171173211759
Meat1271271275112783

 

 

As you can see, the Gross Margin Carrefour measure is constant for all supermarkets and products in the same city.

However, I am getting this result:

 

  CarrefourCarrefourMercadonaMercadonaDíaDía
  Gross Margin CarrefourGross MarginGross Margin CarrefourGross MarginGross Margin CarrefourGross Margin
MadridEggs100100101,29810055
Milk1201201203712224
Meat130130134,34313189
BarcelonaEggs102102102,399102,232
Milk1221221212212256
Meat1321321325013378
ValenciaEggs979799969735
Milk11711710332116,559
Meat127127127,15112883

 

The measure I am using right now is:

Gross Margin Carrefour = CALCULATE (

[Gross Margin],
Master[Supermarkets] = "Carrefour"
  )
5 REPLIES 5
BeaBF
Super User
Super User

@armvime Hi! Try with:

Gross Margin Carrefour =
CALCULATE(
[Gross Margin],
Master[Supermarkets] = "Carrefour",
ALLEXCEPT(Master, Master[Products], Master[City])
)

The ALLEXCEPT function removes the filters from the other supermarkets while keeping the filters for products and cities intact.

BBF

Thanks for your answer, it gets better, but it is not the ultimate solution. Now I have the same Carrefour Gross Margin for all supermarkets and same city and product. However, it does not match the original Gross Margin for Carrefour supermarket. That is, my table is now like this:

 

  CarrefourCarrefourMercadonaMercadonaDíaDía 
  Gross Margin CarrefourGross MarginGross Margin CarrefourGross MarginGross Margin CarrefourGross Margin 
MadridEggs9810098989855 
Milk1171201173711724 
Meat1331301334313389 
BarcelonaEggs1011021019910132 
Milk1211221212212156 
Meat1341321345013478 
ValenciaEggs96,29796,29696,235 
Milk1191171193211959 
Meat1301271305113083 

@armvime Try with:

Gross Margin Carrefour =
CALCULATE(
[Gross Margin],
KEEPFILTERS(Master[Supermarkets] = "Carrefour"),
ALLEXCEPT(Master, Master[Products], Master[City])
)
If it still doesn't work, can you share the PBIX file and tell me the desired output? So that I can test it directly on the dataset.

BBF

bhanu_gautam
Super User
Super User

@armvime , Try using below measure

 

Gross Margin Carrefour =
CALCULATE(
[Gross Margin],
Master[Supermarkets] = "Carrefour",
REMOVEFILTERS(Master[Supermarkets])
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks for your answer, it stays as it is, the table is unchanged.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.