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.
Hi experts,
I'm new to dax and I want to count the number of users registered from the previous period selected on a slicer. DimTimeRegister[Date]) is referred to the slicer and DimTimeRegister[Date_Name] is from my master calendar
In this example, if I have selected this dates, the idea is to count the # of users of previous 6 days (30/06/2019 - 24/06/2019)
This is the model, where the slicer is DimTimeRegister[Date]:
I added an advance card, but it's not working.
And this is my dax formula
registered users. prev. selected = calculate( distinctcount(DimFan[IdUser]); FILTER(all(DimTimeRegister); DimTimeRegister[Date_Name] >= max(DimTimeRegister[Date])+DATEDIFF(min(DimTimeRegister[Date]); max(DimTimeRegister[Date]);DAY)); FILTER(all(DimTimeRegister); DimTimeRegister[Date_Name] <= min(DimTimeRegister[Date])) )
Solved! Go to Solution.
I could solve the problem. If someone is in the same situation, here's what I did:
I've created two dates measures, to get the max and min date of the slicer:
DATE_INI = min(DimTime[Date]) DATE_MAX = max(DimTime[Date]) Then, I did create my measure Users period before = var rang = DATEDIFF([DATE_INI];[DATE_MAX];DAY)+1 return CALCULATE( distinctcount([IdUser]); DATESINPERIOD(DimTime[Date];[DATE_INI];-rang;DAY) )DimTime[Date] is the slicer. It works for me perfect
I could solve the problem. If someone is in the same situation, here's what I did:
I've created two dates measures, to get the max and min date of the slicer:
DATE_INI = min(DimTime[Date]) DATE_MAX = max(DimTime[Date]) Then, I did create my measure Users period before = var rang = DATEDIFF([DATE_INI];[DATE_MAX];DAY)+1 return CALCULATE( distinctcount([IdUser]); DATESINPERIOD(DimTime[Date];[DATE_INI];-rang;DAY) )DimTime[Date] is the slicer. It works for me perfect
Hi @Anonymous ,
I suggest you try using a irrelative date as a date slicer. I create a sample you can reference to modify yours.
I created a calendar table and use the date as a slicer to filter. And there is no relationship among the tables.
Measure = CALCULATE(DISTINCTCOUNT(DimFan[IdUser]),FILTER(DimTimeRegister,DimTimeRegister[Date_Name] >= MIN('Table'[Date]) && DimTimeRegister[Date_Name] <= MAX('Table'[Date])))
If it still don’t work, please share more details and post some sample data. Then we can help you as soon as possible.
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
116 | |
102 | |
77 | |
77 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |