cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PeteGen Frequent Visitor
Frequent Visitor

Filtering and relationships in Power BI

Hi everyone,

 

I have a theoretical question about how Power BI filters and how relationships work. For example, if I have a Registrations table and a Date table in Visual Studio and a DAX measure which reads:

Client Registrations:= CALCULATE(DISTINCTCOUNT(‘Registrations’[ClientID]), FILTER(Registrations, ‘Registrations’[Commencement Date] <=MAX(‘Date’[Date] && ‘Registrations’[Expiry Date] >=MIN(‘Date’[Date]))

 

In Power BI the above measure is used in a visual with Month Name = June, Day Of Month = 30 and Year is 2010, 2011, 2012, 2013, etc from the Date table used as Visual Filters.

 

My question is, are the Date filters above going through the measure and determining whether the Commencement Date and/or Expiry Date are equal to, for example ‘2011-06-30’ etc. in the Commencement Date and Expiry Date columns within the Registrations table? Or is something else happening behind the scenes?

 

Also there is no relationship between the Registration table and the Date table. But if there was 2 one-to-many relationships from Date column to Commencement Date and Expiry Date with the Expiry Date relationship set to inactive would this have an effect?

 

Another example is that I have a Licence table with Issue Date and Expiry Date with one-to-many relationships from Date column to Issue Date and Expiry Date with the Expiry Date relationship inactive. There is a DAX measure counting the number of clients with a certain licence class e.g. car, bike, etc.

Car := CALCULATE(DISTINCTCOUNT(‘Licences’[ClientID]), ‘Licences’[Licence Class] = “C”)

 

Same situation in Power BI where with Month Name = June, Day Of Month = 30 and Year is 2010, 2011, 2012, 2013, etc from the Date table used as Visual Filters.

 

However, the Issue Date and Expiry Date are for the Licence itself and not the entitlement. Is Power BI still filtering the numbers based on the one-to-many relationships between Date column in Date table and Issue Date and Expiry Date in Licences table?

 

If anyone can explain this to me it would be greatly appreciated 🙂

 

Regards,

PeteGen

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Filtering and relationships in Power BI

Hi @PeteGen 

 

Please find my comments below:

 

  1. My question is, are the Date filters above going through the measure and determining whether the Commencement Date and/or Expiry Date are equal to, for example ‘2011-06-30’ etc. in the Commencement Date and Expiry Date columns within the Registrations table? Or is something else happening behind the scenes?

 

Yes. The measure will go through the columns [Commencement Date] and [Expiry Date] to filter row by row which fit the conditions. And keep the rows satisfied , or vice versa.

 

  1. Also there is no relationship between the Registration table and the Date table. But if there was 2 one-to-many relationships from Date column to Commencement Date and Expiry Date with the Expiry Date relationship set to inactive would this have an effect?

 

The relationship won’t affect the results above currently. But if you apply the Date[date] as a filter ( example, select one date of the table), the results will be different.

 

  1. However, the Issue Date and Expiry Date are for the Licence itself and not the entitlement. Is Power BI still filtering the numbers based on the one-to-many relationships between Date column in Date table and Issue Date and Expiry Date in Licences table?

the relationship won’t affect the measure : Car := CALCULATE(DISTINCTCOUNT(‘Licences’[ClientID]), ‘Licences’[Licence Class] = “C”), but if you applied the filter of Date table, the result would be different. Coz the Licences table will be filtered by the date column in Date table.

 

Generally, the relationship created is for better filtering, once the filter of table1 applied, the unrelated rows in table2 would be removed. If measure added, the results will also be rearranged coz the table based has been filtered.

If you’d like to manage multiple dates relationship , USERELATIONSHIP can help, please refer to the official document for details: https://docs.microsoft.com/en-us/dax/userelationship-function-dax

 

Best regards,

Dina Ye

Community Support Team _ Dina Ye
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

2 REPLIES 2
Community Support Team
Community Support Team

Re: Filtering and relationships in Power BI

Hi @PeteGen 

 

Please find my comments below:

 

  1. My question is, are the Date filters above going through the measure and determining whether the Commencement Date and/or Expiry Date are equal to, for example ‘2011-06-30’ etc. in the Commencement Date and Expiry Date columns within the Registrations table? Or is something else happening behind the scenes?

 

Yes. The measure will go through the columns [Commencement Date] and [Expiry Date] to filter row by row which fit the conditions. And keep the rows satisfied , or vice versa.

 

  1. Also there is no relationship between the Registration table and the Date table. But if there was 2 one-to-many relationships from Date column to Commencement Date and Expiry Date with the Expiry Date relationship set to inactive would this have an effect?

 

The relationship won’t affect the results above currently. But if you apply the Date[date] as a filter ( example, select one date of the table), the results will be different.

 

  1. However, the Issue Date and Expiry Date are for the Licence itself and not the entitlement. Is Power BI still filtering the numbers based on the one-to-many relationships between Date column in Date table and Issue Date and Expiry Date in Licences table?

the relationship won’t affect the measure : Car := CALCULATE(DISTINCTCOUNT(‘Licences’[ClientID]), ‘Licences’[Licence Class] = “C”), but if you applied the filter of Date table, the result would be different. Coz the Licences table will be filtered by the date column in Date table.

 

Generally, the relationship created is for better filtering, once the filter of table1 applied, the unrelated rows in table2 would be removed. If measure added, the results will also be rearranged coz the table based has been filtered.

If you’d like to manage multiple dates relationship , USERELATIONSHIP can help, please refer to the official document for details: https://docs.microsoft.com/en-us/dax/userelationship-function-dax

 

Best regards,

Dina Ye

Community Support Team _ Dina Ye
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

Community Support Team
Community Support Team

Re: Filtering and relationships in Power BI

Hi @PeteGen ,

 

If my above post helps, could you please consider Accept it as the solution to help the other members find it more quickly. thanks!

 

Best regards,

Dina Ye

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

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)