cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Count users from previous dates, based on slicer selections

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)

 

periodo.png

 

This is the model, where the slicer is DimTimeRegister[Date]:

Model.png

 

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]))
    )
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

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

View solution in original post

v-xuding-msft
Community Support
Community Support

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])))

1.png2.png

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.

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.

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors