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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rlhim
Helper I
Helper I

Problem counting from two databases based on various conditions

I have two databases one of supervisors and one of subordinates. I need to count the amount of times a supervisor and a subordinate have the same place, shift and Date.

What I have only considers if the conditions are true but doen't count them.

Table of Supervisors

SupDateShiftPlace

Rachel11/12/20230000NY
Rachel11/13/20230000NY
Rachel11/14/20230000NY
Rachel11/15/20230000BT
Rachel11/16/20231600NY
Rachel11/17/20231600AT
Rachel11/18/20230800BT
Brown11/12/20230000AT
Brown11/13/20230000AT
Brown11/14/20230000AT
Brown11/15/20230800NY
Brown11/16/20230800BT
Brown11/17/20230800BT
Brown11/18/20230800NY

Table of subordinates

SubDateShiftPlace

Taylor11/12/20230000NY
Taylor11/13/20230000NY
Taylor11/14/20230000NY
Taylor11/15/20230000NY
Thomas11/16/20231600NY
Thomas11/17/20231600AT
Thomas11/18/20231600BT
Taylor11/12/20230000AT
Taylor11/13/20230000AT
Taylor11/14/20230000BT
Thomas11/15/20230800NY
Thomas11/16/20230800BT
Thomas11/17/20230800BT
Thomas11/18/20230800NY

The correct answer would be

 RachelBrown
Taylor32
Thomas14

 

What I have until now is:

 

 

Same = 
IF (
    CONTAINS (
        Sup,
        Sup[Date], MAX(Sub[Date]),
        Sup[Shift], MAX(Sub[Shift]),
        Sup[Place], MAX(Sub[Place])
    ),
    0,
    1
)

 

 

 

Please help

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

I think there's a slight difference in the result.

 

lbendlin_0-1696711244387.png

 

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Please find attached the PBI file.

Ashish_Mathur_0-1696730291658.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

I think there's a slight difference in the result.

 

lbendlin_0-1696711244387.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.