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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Calculation Help need to pick your brain

Hi  I am doing a direct query report.  I have a Store Slicer on the top. 

 

When you select a store from slicer , i get list of customers for that particular store  lets says 10 customers from our fact table. 

 

I want to find number of times those 10 customers purchased from all other stores except the selected store for this year and pevious year and forever.

 

How can i approach this in DAX?

Thanks.  

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

You need to first create a slicer table with all distinct values of stores;

Then create a measure as below:

Measure = 
var _selectedcustomers=CALCULATETABLE(VALUES('Table'[Customer ]),FILTER(ALL('Table'),'Table'[Store]=SELECTEDVALUE('Slicer table'[Store])))
Return
COUNTX(FILTER('Table','Table'[Customer ] in _selectedcustomers&&'Table'[Store]<>SELECTEDVALUE('Slicer table'[Store])&&'Table'[Year]=YEAR(TODAY())||'Table'[Year]=YEAR(TODAY())-1),'Table'[Store])

And you will see:

Annotation 2020-07-22 104845.png

Pls see attachment for details.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

You need to first create a slicer table with all distinct values of stores;

Then create a measure as below:

Measure = 
var _selectedcustomers=CALCULATETABLE(VALUES('Table'[Customer ]),FILTER(ALL('Table'),'Table'[Store]=SELECTEDVALUE('Slicer table'[Store])))
Return
COUNTX(FILTER('Table','Table'[Customer ] in _selectedcustomers&&'Table'[Store]<>SELECTEDVALUE('Slicer table'[Store])&&'Table'[Year]=YEAR(TODAY())||'Table'[Year]=YEAR(TODAY())-1),'Table'[Store])

And you will see:

Annotation 2020-07-22 104845.png

Pls see attachment for details.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Anonymous
Not applicable

Thank you much appreciated. 🙂 

Helpful resources

Announcements
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.