![]() ![]() Thus, as a rule of thumb, wrap any expression for an extended column within a CALCULATE function whenever you move an extended column out from SUMMARIZE into an ADDCOLUMN statement. This is because it returns the number of rows in the entire Store table for each row of the result instead of returning the number of stores for each country. If you rewrite this query by simply moving the Stores extended columns out of the SUMMARIZE into an ADDCOLUMNS function, you obtain the following query that produces the wrong result. Now, consider the following query that you have already seen at the beginning of this article. The previous examples used a scalar expression over a column that was included in the SUMMARIZE output, so the reference to the column value was valid within the row context. The reason is that ADDCOLUMNS operates in a row context that does not automatically propagate into a filter context, whereas the same within a SUMMARIZE is executed into a filter context corresponding to the values in the grouped columns. ![]() The CALCULATE you can see in the best practices template above is not always required, but you need it whenever the contains an aggregation function. The best practice is that, whenever possible, instead of writing
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |