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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Harvey85
Helper I
Helper I

Filter List of Numeric Values from other Table

Hello,

I have the following DAX formula, where I have Table_1 and Table_2 connected by Key_Campaign.

I need to add column "save_date" from Table_2 to Table_1, filtering in Table_2 the following:

 

- Table_2'[catstock] = values starting with "SEA."

- Table_2'[labor] = value "Season Leaf"

 

End_Date = MAXX(FILTER('Table_2', 'Table_1'[Key_Campaign] = 'Table_2'[Key_Campaign] && CONTAINSSTRING('Table_2'[labor], "Season Leaf") && CONTAINSSTRING('Table_2'[catstock], "SEA.")), 'Table_2'[save_date])
 
Now I have a list of values where I need to replace the condition CONTAINSSTRING('Table_2'[labor], "Season Leaf") and filter the values by Labor_Id, those who have Valid = "Yes". In this case, I should filter values 55 and 58. I have the field Labor_Id in Table_2 (but not the column "Valid").
 
LaborLabor_IdValid
Season Leaf55Yes
Season Land58Yes
Season Stat60No
 
If I'd do that manually, how could I replace the function containsstring to filter values 55 and 58 on a easy way?
 
On the other hand, should I add this table to the model or join it to Table_2? In that case, how could I easily filter the "Yes" values?
 
Thank you!!!
1 ACCEPTED SOLUTION
v-jianpeng-msft
Community Support
Community Support

Hi, @Harvey85 

Based on your description, I have created the following sample data:

Table_1:

vjianpengmsft_0-1709865036462.png

Table_2:

vjianpengmsft_1-1709865062789.png

Labor_Table:

vjianpengmsft_2-1709865089990.png

The relationship between the tables is as follows:

vjianpengmsft_5-1709865666876.png

I'm using the following DAX to filter the rows with Valid = Yes:

End_Date =
VAR _mediumtable =
    SUMMARIZE (
        FILTER ( 'Labor_Table', 'Labor_Table'[Valid] = "Yes" ),
        'Labor_Table'[Labor_Id],
        'Labor_Table'[Labor],
        'Labor_Table'[Valid]
    )
RETURN
    MAXX (
        FILTER (
            'Table_2',
            'Table_1'[Key_Campaign] = 'Table_2'[Key_Campaign]
                && CONTAINSSTRING ( 'Table_2'[catstock], "SEA." )
                && 'Table_2'[Labor_Id] = [Labor_Id]
        ),
        'Table_2'[save_date]
    )

In the variables, I use FILTER to filter out the rows with Valid=Yes. And use the summarize function to summarize, the main purpose is to get the corresponding row name so that this column can be used in MAXX.
The DAX execution result is as follows:

vjianpengmsft_3-1709865568932.png

vjianpengmsft_4-1709865590091.png

I've provided the PBIX file for this time below, and it would be great if it would help you.

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
v-jianpeng-msft
Community Support
Community Support

Hi, @Harvey85 

Based on your description, I have created the following sample data:

Table_1:

vjianpengmsft_0-1709865036462.png

Table_2:

vjianpengmsft_1-1709865062789.png

Labor_Table:

vjianpengmsft_2-1709865089990.png

The relationship between the tables is as follows:

vjianpengmsft_5-1709865666876.png

I'm using the following DAX to filter the rows with Valid = Yes:

End_Date =
VAR _mediumtable =
    SUMMARIZE (
        FILTER ( 'Labor_Table', 'Labor_Table'[Valid] = "Yes" ),
        'Labor_Table'[Labor_Id],
        'Labor_Table'[Labor],
        'Labor_Table'[Valid]
    )
RETURN
    MAXX (
        FILTER (
            'Table_2',
            'Table_1'[Key_Campaign] = 'Table_2'[Key_Campaign]
                && CONTAINSSTRING ( 'Table_2'[catstock], "SEA." )
                && 'Table_2'[Labor_Id] = [Labor_Id]
        ),
        'Table_2'[save_date]
    )

In the variables, I use FILTER to filter out the rows with Valid=Yes. And use the summarize function to summarize, the main purpose is to get the corresponding row name so that this column can be used in MAXX.
The DAX execution result is as follows:

vjianpengmsft_3-1709865568932.png

vjianpengmsft_4-1709865590091.png

I've provided the PBIX file for this time below, and it would be great if it would help you.

 

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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