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
SadStatue
Helper II
Helper II

How to find the people met each other in a same place

Hi everyone,

 

my fact table showing the shifts details as below:

Shift IDStaff NameLocation Nameshift startshift end
1001Aaa10/08/2020 13:0010/08/2020 18:00
1002Baa10/08/2020 13:0010/08/2020 15:00
1003Caa10/08/2020 13:0010/08/2020 15:00
1004Daa10/08/2020 13:0010/08/2020 17:00
1005Eaa10/08/2020 19:0010/08/2020 20:00
1006Faa12/08/2020 21:3013/08/2020 6:30
1007Gaa12/08/2020 21:3013/08/2020 6:30
1008Hbb13/08/2020 14:0013/08/2020 15:00
1009Ibb13/08/2020 15:0013/08/2020 18:00
1010Jbb13/08/2020 13:0013/08/2020 14:00
1011Abb13/08/2020 13:0013/08/2020 16:00
1012Kbb13/08/2020 17:0013/08/2020 21:00

 

I want to make a report that when we select a staff it show me all other staff that was in contact with the selected staff.

so if I select A it should be able to identifie all othe staff who was in contact with A:

Selected stafflocatitondatemet staff
Aaa10/08/2020B
Aaa10/08/2020C
Aaa10/08/2020D
Abb13/08/2020H
Abb13/08/2020I
Abb13/08/2020J

 

Could you please help me define a measure that can provide such a result. or if I need to make any change to data model by creating more table and relations?

 

Thanks,

7 REPLIES 7
pranit828
Community Champion
Community Champion

HI @SadStatue 

try this create a table as below and filter on [Staff Name]

Table = 
GENERATE(
    Table,
    SELECTCOLUMNS(
        CALCULATETABLE(
            VALUES( Table[Staff Name] ),
            (EARLIER((Table[shift start]) <= Table[shift start] &&
             EARLIER(Table[shift end]) > Table[shift Start]) ||
            (EARLIER((Table[shift end]) >= Table[shift start] &&
             EARLIER(Table[shift start]) < Table[shift Start])
            )
        ),
        Table[Shift ID], Table[Staff Name], Table[Location Name], Table[Staff Name],"MetStaff"
    )
)

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Hi Pranti,

 

Thank you for your response But I cannot create such a table as it seems there are some syntax erros cus it doesn't recognise the column in second EARLIER.

It would be appreciated if you re-look at your response to see why its not applicable

 

Cheers,

 

Greg_Deckler
Super User
Super User

@SadStatue - Tough one. It's 1AM here and ..., closest I have been able to come is:

Measure 16 = 
    VAR __Name = MAX([Staff Name])
    VAR __Start = MAX([shift start])
    VAR __End = MAX ([shift end])
    VAR __Table = FILTER(ALL('Table (16)'),[Staff Name] <> __Name && ([shift start] >= __Start && [shift end] <= __End))
RETURN
    CONCATENATEX(__Table,[Staff Name],",")

Needs work. PBIX is attached below sig. It's close. Table 16, Page 16. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,


Thank you for your support and quick response even on midnight!

I've tried what you suggested but as it doesnt cover the location I changed it in the following way

Measure 16 =
VAR __Name = MAX([Staff Name])
VAR __Start = MAX([shift start])
VAR __End = MAX ([shift end])
VAR __Location = MAX([location])
VAR __Table = FILTER(ALL('Table (16)'),[Staff Name] <> __Name && ([shift start] >= __Start && [shift end] <= __End) && [location]=__Location)
RETURN
CONCATENATEX(__Table,[Staff Name],",")

It provide some results but it wasn't accurate. I feel the shift time comparison is not properly defined as any cross between shifts is acceptable (If I understand the logic of the measure properly it should be sth like: ([shift start] >= __Start && [shift start] <= __End)OR([shift end] <= __End && [shift end] >= __Start) OR ([shift start] <= __Start && [shift end] >= __End) )

 

But still it is not working yet.

 

It would be great if you can have a second look at your answer and refine it in a way it works.

 

Cheers,

 

amitchandak
Super User
Super User

@SadStatue , try a measure like this and check

measure =
var _staff = filter(distinct(Table[shift start]), table[Staff Name] in allselected(table[Staff Name])) // or use -- in values(table[Staff Name])
return
calculate(countrows(Table),all(table[Staff Name]), filter(Table, Table[shift start] in _staff))

Hi Amit

 

Thank you for your response. But I couldn't create such a measure.

When I use "distinct(Table[shift start])" then I cannot use "table[Staff Name]" as the next argument. And when I just use "distinct(Table)" then I see an error of "The number of arguments is invalid. Function CONTAINSROW must have a value for each column in the table expression" although I havn't use "CONTAINSROW" at all!!

 

Could you please re-look at it and see whats wrong with it?

 

Cheers,

Hi @SadStatue ,

You can refer to following link to use 'crossjoin' to expand your date range and link to the raw table, then you can create a table with expand table fields and use filter to interaction with these records to achieve your requirement:

Spread revenue across period based on start and end date, slice and dase this using different dates 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.