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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PeteGen
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
v-diye-msft
Community Support
Community Support

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
v-diye-msft
Community Support
Community Support

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.