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
tim10
Helper I
Helper I

Dax works in measure but not in column

Hello

 

I have 2 tables:

a) one is a disconnected table with a list of years : 2020, 2021, 2022.

In this one i have a measure with this code:

Selected RY = selectedvalue('Reporting Year'[ReportingYear])

 

b) one is a table with periods

In this one i have a measure with this code:

 

CY0 Delayed =
var yeartoday=year(today())

return
SWITCH(true(),
month(today())=2 && day(today())<=[Hide Show Day], yeartoday-1,
month(today())=1, yeartoday-1
,yeartoday
)

 

I've also built one column and one measure that have identical code. They can be found in this archive: Link 

If i put these 2 in a table, the measure shows everything correctly while the column does not.

Could you please guide me to understand why this is happening? Thank you

 

compare.png

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Measures and calculated columns are pretty different:

https://radacad.com/measure-vs-calculated-column-the-mysterious-question-not

 

In addition to the whole row context vs filter context thing, a calculated column cannot read slicer values since it's only calculated once each time the model is initially loaded or refreshed, not in response to user interactions via slicers or filters.

 

 

View solution in original post

2 REPLIES 2
v-henryk-mstf
Community Support
Community Support

Hi @tim10 ,

 

As @AlexisOlson  said, there are some differences between a calculated column and a measure.


The calculated column is an extension of the table calculated for each row, and the general grouping filter uses the EARILER function more frequently.

Measure is handled differently than any other table column. Unlike calculated columns, measure is dynamically evaluated with each change in context. If the date filter is changed from 2019 to 2020, all measures will be calculated again. additionally measures are intended to be used as aggregates. Each calculated measure must contain an aggregation function, such as AVG or SUM. if there is no aggregation function, the formula for the measure will show an error.

You can refer to the following blogs to deepen your understanding of both.

Power BI Tutorial: When to Use Calculated Columns and Measures (insightsoftware.com)


If the problem is still not resolved, please point it out and provide test data. Looking forward to your reply.


Best Regards,
Henry


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

AlexisOlson
Super User
Super User

Measures and calculated columns are pretty different:

https://radacad.com/measure-vs-calculated-column-the-mysterious-question-not

 

In addition to the whole row context vs filter context thing, a calculated column cannot read slicer values since it's only calculated once each time the model is initially loaded or refreshed, not in response to user interactions via slicers or filters.

 

 

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.