Forum Discussion
Optimize DAX Code
tamerj1 thank you for your effort,
The formula works quite fast, but it gives a wrong result. It does not calculate the number of unique stores visited within the selected period grouped by the last visit date like in the original attachment i have provided.
Anonymous
I tried hard to understand your your requirement and the numbers that are generated in your sample file and failed to understand what they really represent. Please clarify with some examples
- Anonymous3 years agoNot applicable
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
- ppm13 years agoSolution Sage
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