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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors