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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Qotsa
Helper V
Helper V

Count if not in another table

Hi,

 

I have an SQL DB with 2 tables, Staff & Pay.

 

There is a Many  to one rel-ship based on Staff ID column.

 

A staff is active or inactive based on their start & end date. If end date is blank then staff is active. If end date is before current day then staff is inactive etc.

 

Table Pay has a date column that shows every day a staff got paid.

 

What I need to show is for every Week in Table Pay, the number of staff that were Active in that week but did not get paid i.e they did not work.

 

I don't even know if this is possible or where to start with this.

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Qotsa,

 

Could you please mark the proper answers as solutions?

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Qotsa,

 

Please download a demo from the attachment. If you have a similar scenario, you can try it out.

Measure =
SUMX (
    ADDCOLUMNS (
        Staff,
        "IfNotPaid", IF (
            CALCULATE (
                COUNTROWS ( Pay ),
                FILTER (
                    Pay,
                    Pay[Date] >= MIN ( Staff[Start] )
                        && Pay[Date]
                            <= IF ( ISBLANK ( Staff[End] ), DATE ( 9999, 12, 31 ), MIN ( Staff[End] ) )
                        && Pay[Pay] <> 0
                        && NOT ISBLANK ( Pay[Pay] )
                )
            ) < 5,
            1,
            0
        )
    ),
    [IfNotPaid]
)

Count-if-not-in-another-table

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
LivioLanzo
Solution Sage
Solution Sage

Hello @Qotsa,

 

would you mind posting a sample of your data set?

 

thank you

 


 


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


Proud to be a Datanaut!  

Hi @LivioLanzo,

 

Thanks for your reply. I'm not sur how I'd even do that except for uploading the whole pbix.

@Qotsa it is possible to post tabular data which can be copy pasted

 


 


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


Proud to be a Datanaut!  

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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