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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Filter by two columns

Hi,
I have a table with reservations like this:

ReservationIDAreaDatePerson
11st floor01.11.2020A
2kitchen02.11.2020A
3kitchen03.11.2020C
4garden01.11.2020D
5garden02.11.2020E
6kitchen02.11.2020F
71st floor01.11.2020G

 

I'd like to have a measure that gives me all contacts of a selected person. Contacts are based on sameDate AND sameArea.
The result should look like this ("All contacts of Person A"):

PersonPrimaryContacts
AF, G

 

F and G because they we're at the same area at the same date.

 

Do you have any ideas to solve this? Please help me!
Thank you

2 ACCEPTED SOLUTIONS
camargos88
Community Champion
Community Champion

@Anonymous ,

 

Try this measure:

_Contact = 
VAR _person = SELECTEDVALUE('Table'[Person])
VAR _tblAreaDate = SELECTCOLUMNS(ADDCOLUMNS(SUMMARIZE(FILTER(ALL('Table'), 'Table'[Person] = _person), 'Table'[Area], 'Table'[Date]), "Combine", COMBINEVALUES(",", 'Table'[Area], 'Table'[Date])), "Combine", [Combine])
VAR _tblMatch = CALCULATETABLE(
                VALUES('Table'[Person]), FILTER(ALL('Table'), COMBINEVALUES(",", 'Table'[Area], 'Table'[Date]) in _tblAreaDate && 'Table'[Person] <> _person))


RETURN CONCATENATEX(_tblMatch, 'Table'[Person], ",")


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

AlB
Community Champion
Community Champion

Hi @Anonymous 

1. Place [Person] in a table visual

2. Create this measure and place it in the visual

 

Primary contacts = 
VAR datesAreas_ = SUMMARIZE ( Table1, Table1[Area], Table1[Date] )
VAR currentPerson_ = SELECTEDVALUE ( Table1[Person] )
VAR contacts_ =
    CALCULATETABLE (
        DISTINCT ( Table1[Person] ),
        datesAreas_,
        Table1[Person] <> currentPerson_
    )
RETURN
    CONCATENATEX ( contacts_, [Person], ", " )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

Hi @Anonymous 

1. Place [Person] in a table visual

2. Create this measure and place it in the visual

 

Primary contacts = 
VAR datesAreas_ = SUMMARIZE ( Table1, Table1[Area], Table1[Date] )
VAR currentPerson_ = SELECTEDVALUE ( Table1[Person] )
VAR contacts_ =
    CALCULATETABLE (
        DISTINCT ( Table1[Person] ),
        datesAreas_,
        Table1[Person] <> currentPerson_
    )
RETURN
    CONCATENATEX ( contacts_, [Person], ", " )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

camargos88
Community Champion
Community Champion

@Anonymous ,

 

Try this measure:

_Contact = 
VAR _person = SELECTEDVALUE('Table'[Person])
VAR _tblAreaDate = SELECTCOLUMNS(ADDCOLUMNS(SUMMARIZE(FILTER(ALL('Table'), 'Table'[Person] = _person), 'Table'[Area], 'Table'[Date]), "Combine", COMBINEVALUES(",", 'Table'[Area], 'Table'[Date])), "Combine", [Combine])
VAR _tblMatch = CALCULATETABLE(
                VALUES('Table'[Person]), FILTER(ALL('Table'), COMBINEVALUES(",", 'Table'[Area], 'Table'[Date]) in _tblAreaDate && 'Table'[Person] <> _person))


RETURN CONCATENATEX(_tblMatch, 'Table'[Person], ",")


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



mahoneypat
Microsoft Employee
Microsoft Employee

You can use this measure expression in a table visual with your Person column to get the shown result.  Replace Reservations with your actual table name.  Note this has two CONCATENATEX functions.  A virtual table is made for all the combinations of place and date for that person.  The first concat combines all the people that overlapped in each place time with commas.  The second concat combines those individual list into a full list separate by semi colons.

 

mahoneypat_0-1604671792100.png

 

SamePlaceDate =
VAR thisperson =
    MIN ( Reservations[Person] )
VAR summary =
    ADDCOLUMNS (
        SUMMARIZE (
            Reservations,
            Reservations[Area],
            Reservations[Date]
        ),
        "overlap",
            CONCATENATEX (
                CALCULATETABLE (
                    DISTINCT ( Reservations[Person] ),
                    Reservations[Person] <> thisperson
                ),
                Reservations[Person],
                ", "
            )
    )
RETURN
    CONCATENATEX (
        summary,
        [overlap],
        "; "
    )

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors