Forum Discussion

starry's avatar
starry
Frequent Visitor
3 years ago
Solved

Error in DAX formula

Hi All I have a formula Signup vs Deposit = IF('Table1'[Days btw sign up &Deposit] < 1 && 'Table1'[Days btw sign up and today] < 3, 2, IF('Table1'[Days btw sign up and today] >= 3 && 'Table1'[Da...
  • djurecic's avatar
    3 years ago

    Hi starry 

    The Dax you have there would need to be a calulated column, not a measure.

     

    Here is some additional information:

    https://endjin.com/blog/2022/04/measures-vs-calculated-columns-in-dax#:~:text=When%20you%20write%20an%20expression,work%20at%20the%20aggregate%20level.

     When you write an expression in a calculated column, the expression is evaluated for each row of the table. The calculated column has knowledge of the current row.

    By contrast, measures implicitly do not have a row context. This is because, by default, they work at the aggregate level. So, you cannot refer to columns directly in a DAX measure, you will get an error because no row context exists. This is because the measure will not know which row to choose in the table. In order to reference a column in a measure, you must wrap the column in an aggregation function. As we are aggregating values, it doesn't matter which row we are using, we do not need a row context, as we are just aggregating all of the values in a single column to return a single value. Alternatively, we can create a row context in a measure by using an iterator function. This topic will be explained further in the following section.