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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MarketingGerens
Frequent Visitor

FILTER TABLE BASED ON ANOTHER TABLE

Hi

I have this 2 tables on my dashboard:

 

TABLE1CUSTOMERS

CUSTOMERID   |  PRODUCTIDPURCHASE  |  REGISTER_DATE

________________________________________________________________

101                   |   C01                                 |   20/11/2019

102                   |   C02                                 |   20/12/2019

 

TABLE2PRODUCTS

PRODUCTID |  LAUNCH_DATE

___________________________________

C01               |   19/11/2019

C02               |   22/11/2019

 

I would like to filter CUSTOMERID's out based on whether DATE1 is earlier than DATE2 to see how many new customers bought a product. I was thinking to do this using the DAX below:

 

NEW CUSTOMERS =

CALCULATE(

COUNT(TABLE1CUSTOMERS[CUSTOMERID]), FILTER('TABLE1CUSTOMERS','TABLE1CUSTOMERS'[REGISTER_DATE]>'TABLE2PRODUCTS'[LAUNCH_DATE])

)

 

but this is giving me an error because I can't use the FILTER function by referring to another table. Can somebody help me?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello,

As you are trying to access the rows of a table on the one side of the relationship from the many side of the relationship, you need to use RELATED function.

NEW_CUSTOMERS = COUNTX(FILTER(Cust,Cust[REGISTER_DATE]>RELATED(Products[LAUNCH_DATE])),Cust[CUSTOMERID]).

Though using CALCULATE function too we could achieve the same result.

This is yet another way of achieving it, without using calculate.

 

Regards,

Rakesh

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hello,

As you are trying to access the rows of a table on the one side of the relationship from the many side of the relationship, you need to use RELATED function.

NEW_CUSTOMERS = COUNTX(FILTER(Cust,Cust[REGISTER_DATE]>RELATED(Products[LAUNCH_DATE])),Cust[CUSTOMERID]).

Though using CALCULATE function too we could achieve the same result.

This is yet another way of achieving it, without using calculate.

 

Regards,

Rakesh

V-pazhen-msft
Community Support
Community Support

@MarketingGerens 

It seems your tables are related by product ID, you need to use RELATED() when referring to THE other table columns. 

 

NEW CUSTOMERS = CALCULATE(COUNT(Table1[ID]), FILTER('Table1','Table1'[Register Date]>RELATED(Table2[Launch Date])))

 


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

amitchandak
Super User
Super User

You can have a new column in table1customer, that can help you to solve the problem

 

minx(FILTER('TABLE2PRODUCTS','TABLE1CUSTOMERS'[REGISTER_DATE]>'TABLE2PRODUCTS'[LAUNCH_DATE] 
&& 'TABLE1CUSTOMERS'[PRODUCTID ]='TABLE2PRODUCTS'[PRODUCTID ]),'TABLE2PRODUCTS'[LAUNCH_DATE])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.