Forum Discussion

smoortema's avatar
smoortema
Frequent Visitor
4 years ago
Solved

Filtering dimensions in a calculated column

I have a table with prices, for shops, products and dates, and I have a separate dimension table for each dimension. I would like to identify erroneous data in the price column by searching for outli...
  • AllisonKennedy's avatar
    4 years ago

    smoortema  Why are you creating this as a calculated column?

     

    Be really careful using aggregate functions within calculated columns - it does not provide the right context and is possibly what you mean when you say 'I have learned that CALCULATE is the best practice in these cases'

     

    CALCULATE puts you into a filter context, so converts the calculated column into a single measure, taking the current row values as the filter context for that measure. Since it puts you into an equivalent filter context, your column references will behave differently than you might expect. 

     

    If I understand your question properly (again still not sure why you're doing this as a column and not a measure), you could try:

     

    PriceFirstQuartile =
    CALCULATE(
        PERCENTILEX.INC('Price','Price'[Price]0.25),
        ALLEXCEPT('Price',
        'Price'[ARTICLE_CODE],
        'Price'[DATE],
        'Price'[SHOP_TYPE_CODE]
         )
    )