Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
garrenr14
Frequent Visitor

Help Filtering Table

Hello all,

 

Given the following data set:

 

NameDate SeenRelative Date Seen
Liam1/8/2021Today
Noah1/8/2021Today
Emma1/8/2021Today
Oliver1/8/2021Today
Ava1/8/2021Today
William1/8/2021Today
Olivia1/7/2021Yesterday
Emma1/7/2021Yesterday
William1/7/2021Yesterday
Sophia1/7/2021Yesterday
Olivia1/6/2021Two Days Ago
Noah1/6/2021Two Days Ago
Emma1/6/2021Two Days Ago
Ava1/6/2021Two Days Ago
William1/6/2021Two Days Ago
Sophia1/6/2021Two Days Ago

 

Would it be possible to generate the following three lists?

 

New People - Not Seen Before Today
Liam
Oliver

 

Missing People - Seen Yesterday but not Today
Olivia
Sophia

 

Returning People - Seen Two days ago and Today but not Yesterday
Noah
Ava

 

It feels like this should be a basic exercise in using filters but I can't seem to figure it out.

 

Ideally, the 'relative date' would be a slicer / filter of some sort, so that this view could be generated for previous days.

 

Also, I'm open to hearing your thoughts on the best way to visualize this data. At this time I can only think of a list, but there might be other neat visuals like timelines that would make this data pop.

 

Thanks in advance for all your help!

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@garrenr14 

 

You can create measures as follows:

1) New People:

New people = 
VAR people = VALUES(Table1[Name])
VAR BeforeToday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] <> "Today")
RETURN
COUNTROWS(
      EXCEPT(people, BeforeToday))

 

2) Seen Yesterday but not today:

Seen Yesterday but not today = 
VAR SToday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Today")
VAR SYesterday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Yesterday")
Return
COUNTROWS(
      EXCEPT(SYesterday, SToday)
)

 

3) Returning People:

Returning People = 
VAR _yesterday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Yesterday")
VAR _Today= CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Today")
VAR Days2Ago = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Two Days Ago")
RETURN
COUNTROWS(EXCEPT(
            INTERSECT(_Today, Days2Ago), _yesterday))

 

You can then use these as either measures in a table:

measures.JPG

 

or as filter in the filter pane for each visual:

result.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

@garrenr14 

 

You can create measures as follows:

1) New People:

New people = 
VAR people = VALUES(Table1[Name])
VAR BeforeToday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] <> "Today")
RETURN
COUNTROWS(
      EXCEPT(people, BeforeToday))

 

2) Seen Yesterday but not today:

Seen Yesterday but not today = 
VAR SToday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Today")
VAR SYesterday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Yesterday")
Return
COUNTROWS(
      EXCEPT(SYesterday, SToday)
)

 

3) Returning People:

Returning People = 
VAR _yesterday = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Yesterday")
VAR _Today= CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Today")
VAR Days2Ago = CALCULATETABLE(VALUES(Table1[Name]), Table1[Relative Date Seen] = "Two Days Ago")
RETURN
COUNTROWS(EXCEPT(
            INTERSECT(_Today, Days2Ago), _yesterday))

 

You can then use these as either measures in a table:

measures.JPG

 

or as filter in the filter pane for each visual:

result.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






This is great, thank you! I like how it can be used with filters or measures

littlemojopuppy
Community Champion
Community Champion

Hi  

Sure we can do that!  I added a calculated column like below and then it becomes basic set operations...

Days Since Last Visit = DATEDIFF( 'People Visits'[Date Seen], TODAY(), DAY )

 

People Not Seen Before Today = 
    VAR PeopleSeenToday =
        CALCULATETABLE(
            VALUES('People Visits'[Name]),
            FILTER(
                ALL('People Visits'),
                'People Visits'[Days Since Last Visit] = 0
            )
        )
    VAR PeopleSeenBeforeToday =
        CALCULATETABLE(
            VALUES('People Visits'[Name]),
            FILTER(
                ALL('People Visits'),
                'People Visits'[Days Since Last Visit] <> 0
            )
        )
    RETURN

    EXCEPT(
        PeopleSeenToday,
        PeopleSeenBeforeToday
    )

 

People Seen Yesterday But Not Today = 
    VAR PeopleSeenToday =
        CALCULATETABLE(
            VALUES('People Visits'[Name]),
            FILTER(
                ALL('People Visits'),
                'People Visits'[Days Since Last Visit] = 0
            )
        )
    VAR PeopleSeenYesterday =
        CALCULATETABLE(
            VALUES('People Visits'[Name]),
            FILTER(
                ALL('People Visits'),
                'People Visits'[Days Since Last Visit] = 1
            )
        )
    RETURN

    EXCEPT(
        PeopleSeenYesterday,
        PeopleSeenToday
    )

 

People Seen Yesterday and Day Before Not Today = 
    VAR PeopleSeenToday =
        CALCULATETABLE(
            VALUES('People Visits'[Name]),
            FILTER(
                ALL('People Visits'),
                'People Visits'[Days Since Last Visit] = 0
            )
        )
    VAR PeopleSeenYesterday =
        CALCULATETABLE(
            VALUES('People Visits'[Name]),
            FILTER(
                ALL('People Visits'),
                'People Visits'[Days Since Last Visit] = 1
            )
        )
    VAR PeopleSeenTwoDaysAgo =
        CALCULATETABLE(
            VALUES('People Visits'[Name]),
            FILTER(
                ALL('People Visits'),
                'People Visits'[Days Since Last Visit] = 2
            )
        ) 
    RETURN

    EXCEPT(
        INTERSECT(
            PeopleSeenToday,
            PeopleSeenTwoDaysAgo
        ),
        PeopleSeenYesterday
    )

 

Hope this helps!  

 

Here's the results of the three tables...

littlemojopuppy_3-1610131557494.png

 

littlemojopuppy_4-1610131578968.png

 

littlemojopuppy_5-1610131597933.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.