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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
AnaBraganca
Frequent Visitor

Filter a query based on a another table

Hello,

I'm struggling to filter a database based on a date listed in another database.

I've seen similar problems here, but so far nothing worked, or I'm getting the coding wrong.

 

I have a database called Existencia, with several rows and three columns. One of the columns has dates, column Dat1. 

I have another database, called Analise,  and I want to filter the date column - called Dia - in the database Analise, to be on or before the latest date from Dat1 in the Existencia database. So I want ----->   Dia <= latest Dat1 

Note: The latest date is constantly changing, the Existencia database source is an Excel file, so new rows created constantly. 

 

I don't want to merge or append, and want to avoid creating another column in the Analise query to meet the condition.

But I'm struggling with the language to filter in the Advanced Editor.

 

1 ACCEPTED SOLUTION

Hi @AnaBraganca ,

I think you can use Parameter in Power Query.

vyilongmsft_0-1711613822124.png

vyilongmsft_1-1711613857127.png

Then you can choose Date Filters and select Before.

vyilongmsft_2-1711613928985.png

vyilongmsft_3-1711614009508.png

Finally you can get the whole days before what you need.

vyilongmsft_4-1711614078466.png

 

 

 

Best Regards

Yilong Zhou

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

4 REPLIES 4
v-yilong-msft
Community Support
Community Support

Hi @AnaBraganca ,

I create two tables as you mentioned, their names are Existencia and Analise.

vyilongmsft_0-1711417732744.png

vyilongmsft_1-1711417762070.png

Then I create a new table and it satisfies your requirements.

Table =
VAR LatestDate =
    MAX ( 'Existencia'[Date1] )
RETURN
    FILTER ( 'Analise', 'Analise'[Dia] <= LatestDate )

vyilongmsft_2-1711417887479.png

 

 

 

Best Regards

Yilong Zhou

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

Hi,

I'm trying to avoid creating another table.

What I'm trying is for this filter to be each [Data] <= the latest date of the Dat1 column (second picture). But this second part of the code is the one I'm struggling with.

 

AnaBraganca_0-1711475781347.png

This is the table with the date I want to filter with.

 

AnaBraganca_1-1711476008928.png

 

In this case, I want the code to filter by 30-06-2023, which will change when a new row is added. 

 

Hi @AnaBraganca ,

I think you can use Parameter in Power Query.

vyilongmsft_0-1711613822124.png

vyilongmsft_1-1711613857127.png

Then you can choose Date Filters and select Before.

vyilongmsft_2-1711613928985.png

vyilongmsft_3-1711614009508.png

Finally you can get the whole days before what you need.

vyilongmsft_4-1711614078466.png

 

 

 

Best Regards

Yilong Zhou

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

I've tried this before going for the Advanced Editor option, but I could never get the parameter to automatically get the last date of the Existencia table.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.