Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Make calculated column based on a variable user-selected date

Hi all,    Looking for help with a calculated column that takes a user-selected date value, and updates the output/dependent column accordingly.    The calculation is essentially: based on a user...
  • v-jingzhang's avatar
    v-jingzhang
    5 years ago

    Hi Anonymous 

     

    Calculated columns are populated when they are created or refreshed. Their data are not able to be changed dynamically according to users' selection in slicers or filters in the report. In order to change the values dynamically according to users' selections, you need a measure to realize it. And the proceeding columns based on this measure should all be realized with measures. 

     

    To avoid the visuals being filtered by the slicer directly, you need to have an independent date table in the data model. This date table has no relationships with other tables and is to be used as a parameter table for users to select an end date from.

     

    Then you can create measures like below.

    Days to end Date = DATEDIFF(SELECTEDVALUE('Table'[Column A]),SELECTEDVALUE('End Date Table'[End Date]),DAY)
    Days Completed = IFERROR(IF([Days to end Date]<1, 1, 2), BLANK())

     

    Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as the solution to help other members find it.