Forum Discussion
Power BI - DAX Concurrent Users Query
- 9 years ago
Hi frb_sega,
I try to reproduce your scenario. The sample data created list the users start-time and end time in the system, I calculate the count if users up to current time.
I create a calendar table using the formula below,Calendar = CALENDAR(MIN(Table2[Month_Start_Date]),MAX(Table2[Month_End_Date]))
Create a measure to calculate the count of users.
count = CALCULATE(COUNTA(Table2[User]),FILTER(Table2,AND(Table2[Month_Start_Date]<=MAX('Calendar'[Date]),Table2[Month_End_Date]>MAX('Calendar'[Date]))))
Finally, create a table, select the CALENDAR[Date], and "count" measure as value level. Please see the following screenshot. Up to 2016/8/1, there are one users online. Until 2016/10/1, there are two users in the system.
If you have any other issue, please feel free to ask.
Best Regards,
Angelia - 9 years ago
FYI, if anytone was looking for further info, I have been given the below code on another forum and it works well:
Calendar = SELECTCOLUMNS ( CROSSJOIN ( CALENDAR (MIN(Sessions[startdate]), MAX(Sessions[enddate]) ), DATATABLE ( "Hour", DATETIME, { { "00:00" }, { "01:00" }, { "02:00" }, { "03:00" }, { "04:00" }, { "05:00" }, { "06:00" }, { "07:00" }, { "08:00" }, { "09:00" }, { "10:00" }, { "11:00" }, { "12:00" }, { "13:00" }, { "14:00" }, { "15:00" }, { "16:00" }, { "17:00" }, { "18:00" }, { "19:00" }, { "20:00" }, { "21:00" }, { "22:00" }, { "23:00" } } ) ), "Date", [Date] + [Hour] )
Thank you so much for the solution. Could you also help me with how should I create a relationship between concurrent users, with the "Start Date and Time"?
I want to create Table 2 visual with Start time, end time, and username. This will be in addition to the Table 1 where I have the calendar date and count
So that, when select an entry from Table 1, it should highlight those entries in Table2 to highlight the concurrent users.