Forum Discussion

az38's avatar
az38
Community Champion
7 years ago
Solved

join generateseries by condition

hello!

 

Ive got a

tablePeriod =  GENERATESERIES (
DATE ( 2018, 5, 1 ),
DATE ( 2018, 5, 3 ),
TIME ( 0, 30, 0 )
)

 

and Ive got a user's session log:

session_id; session_starttime; session_endtime

 

and i need to know count(session_id) for each value from tablePeriod that >=session_starttime and <= session_endtime

 

result is a tablePeriod from two columns: Period, CountSessions

 

Thank you!

 

 


 

  • az38,

     

    You may use DAX below to add a calculated column.

    Column =
    COUNTROWS (
        FILTER (
            'session',
            'session'[session_starttime] <= tablePeriod[Value]
                && 'session'[session_endtime] >= tablePeriod[Value]
        )
    )
    

3 Replies

  • az38's avatar
    az38
    Community Champion

    So, I want to define how many users were active on the server at each moment (each row) from the table tablePeriod 

  • v-chuncz-msft's avatar
    v-chuncz-msft
    Community Support

    az38,

     

    You may use DAX below to add a calculated column.

    Column =
    COUNTROWS (
        FILTER (
            'session',
            'session'[session_starttime] <= tablePeriod[Value]
                && 'session'[session_endtime] >= tablePeriod[Value]
        )
    )