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
campelliann
Post Patron
Post Patron

Theoretical Explanation on Filter/Row Context

Hi,


So I needed to compare a certain date with the End of the month. 

When I use a measure I need to do something like this: 

if(MAX('Calendario Ano (Automatico)'[Date])>EOMONTH(today(),0),0,1)

When I use a calculated column I dont need to use the MAX around date:
if('Calendario Ano (Automatico)'[Date]>EOMONTH(today(),0),0,1)

This would lead me to believe that in tables, the row context "collapses" the table in one row, so power BI knows it must compare the date of the current row with EOMonth. 

But if for instance I were to do another different exercise and calculate the Max Date in a calculated column, power BI would return the max of the entire table not the row. I know I can use calculate to do a context transition to filter context, but this seems contractictory. 

If anyone can explain the logic behind I would be most grateful 🙂 

Best wishes



1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @campelliann 

Thanks for reaching out to us.

To understand that, we need to know the difference between measure and column first:

  • Measures are calculated in the context of visual or DAX queries, and calculated columns are calculated at the row level of the table in which they are located. This is because the calculated columns are calculated row by row, and the measures aggregate the data in the current context. When creating a calculated column, DAX will create a row context by default, use it as a cursor, iterate the table row by row, and evaluate the expression. Therefore, we don't need to manually create the row context. We can directly use table[column] to obtain the contents of the current row.

Then we need to know the row context and the filter context, you can refer to this video:

https://www.youtube.com/watch?v=NkYwwb7I3BY

 

Best Regards,

Community Support Team _Tang

If this post helps, 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-xiaotang
Community Support
Community Support

Hi @campelliann 

Thanks for reaching out to us.

To understand that, we need to know the difference between measure and column first:

  • Measures are calculated in the context of visual or DAX queries, and calculated columns are calculated at the row level of the table in which they are located. This is because the calculated columns are calculated row by row, and the measures aggregate the data in the current context. When creating a calculated column, DAX will create a row context by default, use it as a cursor, iterate the table row by row, and evaluate the expression. Therefore, we don't need to manually create the row context. We can directly use table[column] to obtain the contents of the current row.

Then we need to know the row context and the filter context, you can refer to this video:

https://www.youtube.com/watch?v=NkYwwb7I3BY

 

Best Regards,

Community Support Team _Tang

If this post helps, 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.