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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Omit values based on date within another table

Hi, new to Power Bi but have some SQL experience. Struggling to complete a task and wondered if anyone can help me please?

 

I have Table A which includes a date column (dd/mm/yyyy). It is a standalone table, no relationship to any other tables

I want to filter the contents of Table B whereby if it contains a row of data with a date inlcuded in Table A, it omits the row.

 

E.g.  

Table A

WeekCommencingReportMonthReason
01/01/2023JanuaryChristmas
12/02/2023FebruaryHalf Term
30/04/2023AprilBank Holiday

 

Table B

WeekCommencingSiteIDStaffNo
30/04/2023105
07/05/2023812

 

I would like Table B to omit the row where the date is also shown in Table A - therefore the 30/04/2023 row in this example 

I can then add up the StaffNo row to get a sumtotal, excluding the weeks shown in Table A.

Hopefully this makes sense, please can anyone advise how I can achieve this?

I would assume I can make a calculated column using DAX to achieve this, just not sure which formulae to use.

BTW, Table B has thousands of rows of data which need to be filtered!

Many thanks 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

I created a sample pbix file(see the attachment), please check if that is what you want.

Method1: Handle it in Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtE3NtA3MjAyVtJRMjQAEqZKsTrRSqb65jBRC5CMkVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [WeekCommencing = _t, SiteID = _t, StaffNo = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WeekCommencing", type date}, {"SiteID", Int64.Type}, {"StaffNo", Int64.Type}}),
    #"FilteredTable" =Table.SelectRows( #"Changed Type" , each not List.Contains(#"Table A"[WeekCommencing], [WeekCommencing]))
in
    #"FilteredTable"

vyiruanmsft_0-1693549325205.png

Method2: Create a calculated column and filter it out using visual-level filter

Omit = 
VAR _date =
    CALCULATE (
        MAX ( 'Table A'[WeekCommencing] ),
        FILTER ( 'Table A', 'Table A'[WeekCommencing] = 'Table B(2)'[WeekCommencing] )
    )
RETURN
    IF ( ISBLANK ( _date ), 1, 0)

vyiruanmsft_1-1693550056960.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Many thanks for this, much appreciated. I'll give it a try today.  

Anonymous
Not applicable

Hi @Anonymous ,

I created a sample pbix file(see the attachment), please check if that is what you want.

Method1: Handle it in Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtE3NtA3MjAyVtJRMjQAEqZKsTrRSqb65jBRC5CMkVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [WeekCommencing = _t, SiteID = _t, StaffNo = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WeekCommencing", type date}, {"SiteID", Int64.Type}, {"StaffNo", Int64.Type}}),
    #"FilteredTable" =Table.SelectRows( #"Changed Type" , each not List.Contains(#"Table A"[WeekCommencing], [WeekCommencing]))
in
    #"FilteredTable"

vyiruanmsft_0-1693549325205.png

Method2: Create a calculated column and filter it out using visual-level filter

Omit = 
VAR _date =
    CALCULATE (
        MAX ( 'Table A'[WeekCommencing] ),
        FILTER ( 'Table A', 'Table A'[WeekCommencing] = 'Table B(2)'[WeekCommencing] )
    )
RETURN
    IF ( ISBLANK ( _date ), 1, 0)

vyiruanmsft_1-1693550056960.png

Best Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.