Forum Discussion

Rockwell's avatar
Rockwell
New Member
4 years ago
Solved

Finding subset that satisfies date condition

Hi,

I have a dataset with the following format:

UserID, Date, UniqueID

UserIDDateUnique ID
1Nov 20211
2Nov 20212
3Nov 20213
1Dec 20214
2Dec 20215
1Jan 20226
2Jan 20227
4Jan 20228

 

If I wanted to find the subset of UserIDs that are present at every date, but not those that aren't present at every date how would I approach it? I'm a but stuck here. For example, I'd want the subset of UserIDs that Showed up in November, December and January but not the ones that did not show up at all three dates.

 

Any help is appreciated

 

Thanks

  • Rockwell,

     

    Try this solution.

     

    1. Create measure:

     

    User Filter = 
    VAR vCountUserRows =
        CALCULATE ( COUNTROWS ( Table1 ), ALL ( Table1 ), VALUES ( Table1[UserID] ) )
    VAR vCountDistinctDate =
        CALCULATE ( COUNTROWS ( VALUES ( Table1[Date] ) ), ALL ( Table1 ) )
    VAR vResult =
        IF ( vCountUserRows = vCountDistinctDate, 1 )
    RETURN
        vResult

     

    2. Add measure User Filter to a visual:

     

     

    3. Result:

     

     

2 Replies

  • Rockwell,

     

    Try this solution.

     

    1. Create measure:

     

    User Filter = 
    VAR vCountUserRows =
        CALCULATE ( COUNTROWS ( Table1 ), ALL ( Table1 ), VALUES ( Table1[UserID] ) )
    VAR vCountDistinctDate =
        CALCULATE ( COUNTROWS ( VALUES ( Table1[Date] ) ), ALL ( Table1 ) )
    VAR vResult =
        IF ( vCountUserRows = vCountDistinctDate, 1 )
    RETURN
        vResult

     

    2. Add measure User Filter to a visual:

     

     

    3. Result:

     

     

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity Support

    Hi Rockwell ,

     

    Whether the advice given by DataInsights  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


    Looking forward to your feedback.


    Best Regards,
    Henry