Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Convert static calculated column to dynamic measure

Here is an example of my data:

 

I need a measure that will for each month+day combination, divide the distinct count of the year column based on my filter selection. 

 

So results would look like this:

The result is the years I would select in my filter so 2016 would divide by 1, 2016 and 2017 would divide by 2, etc...

 

I have a calculated column that does this calculation correctly, but it's not dynamic based on filter selections:

 

Avg Amount = DIVIDE('Table'[Amount],CALCULATE(DISTINCTCOUNT('Table'[Year]),ALLEXCEPT('Table','Table'[Month + Day])),0)

 

So I would need help converting this to a dynamic measure.

5 Replies

  • zaza's avatar
    zaza
    Icon for Resolver III rankResolver III

    To make your calculated column into a measure you need to make sure that all elements can be expressed as a single value. So that means wrapping 'Table'[Amount] into an aggregation function like SUM/MAX/AVG.

     

    Avg Amount = DIVIDE(SUM('Table'[Amount]),CALCULATE(DISTINCTCOUNT('Table'[Year]),ALLEXCEPT('Table','Table'[Month + Day])),0)

      

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    hi  Anonymous 

    Just use ALLSELECTED Funtion to create a measrue as below:

    New Avg Amount = DIVIDE(SUM('Table'[Amount]), CALCULATE(DISTINCTCOUNT('Table'[Year]),ALLSELECTED('Table')),0)

     

    Regards,

    Lin