Forum Discussion
Optimize DAX Code
This is an algorithm in steps:
Depending on the date in the column in the matrix visual, filter the Fact table and find the last visit for each store (StoreID, SBO column in the dimEmployee table) for a period of 42 days prior to that date.
Count all unique store numbers for a specific product that I select in the slicer.
The problem arises because in one month, there may be multiple visits to one store, and not all products may be available during each visit. I only need rows with the last visit.
Here is link for excel file:
https://www.dropbox.com/sh/31t6kwe0c885wjt/AAA6R3sYvZr4SuKduYYSwTiBa?dl=0
Still trying to understand the needed logic and made a page to focus on one result from original matrix. For Product 19, Emp 125, and a 42 day range ending on March 1st (your first column), your measure shows a value of 2. Should the last row below on the 18th be excluded? If not, pls clarify how to count the stores to get 2. Since you are looking for max dates, why doesn't a simple distinct count of stores meet the need?
Pat