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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mariebel
Frequent Visitor

DAX: Filter based on property of item in slicer

Hi all, 

 

I've been struggeling with the following for quite a while and I was hoping you guys could help me out. 

 

I am building a report for retail stores in different countries, and with different properties. I would like to compare the sales of store X to stores in the same country, with the same property. So if I filter my report to show the date for store X, it's in the USA and the property is Urban. So I'd like to get the average sales of similar stores, in this case A and Z (see table below) and show it. 

 

How do I do this in DAX? I've tried using SELECTEDVALUE, but if I take a count of the stores, I only get the one for store X. I am completely lost by now. Thanks in advance for your help!!!

 

As for the data: 

 

I have one fact table with sales figures (let's call it Sales) and a measure summing the net sales (called Net Sales) 

And another dimension table with store information, amongst which the country and property info. 

StoreCountryProperty
AUSAUrban
BUSARural
CCanadaRural
XUSAUrban
YCanadaUrban
ZUSAUrban
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @mariebel ,

 

Please check the formula below.

Measure = CALCULATE(AVERAGE('Table'[sales]),FILTER(ALL('Table'),'Table'[Country]=SELECTEDVALUE('Table'[Country])&&'Table'[Property]=SELECTEDVALUE('Table'[Property])&&'Table'[Store]<>SELECTEDVALUE('Table'[Store])))

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @mariebel ,

 

Please check the formula below.

Measure = CALCULATE(AVERAGE('Table'[sales]),FILTER(ALL('Table'),'Table'[Country]=SELECTEDVALUE('Table'[Country])&&'Table'[Property]=SELECTEDVALUE('Table'[Property])&&'Table'[Store]<>SELECTEDVALUE('Table'[Store])))

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

The information you have provided is not making the problem clear to me. Can you please explain with an example. If possible please share a sample pbix file after removing sensitive information.
Thanks.
Proud to be a Datanaut My Recent Blog -Time Intelligence - Direct Query

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.