Forum Discussion

thampton's avatar
thampton
Helper III
7 years ago
Solved

Dynamic Column based on slicer

I have a table with a sales date (per order) and then a disconnected date table. I would like to be able to calculate a dynamic aging based on the slicer selection. 

 

For example, sales order date is 6/07/2019, if i select 6/11/2019, the column would calculate 4. If i select 6/09/2019, the column would calculate 2. 

 

Is there any way to do this? 

6 Replies

  • Cmcmahan's avatar
    Cmcmahan
    Resident Rockstar

    Does this answer look close to what you want? https://community.powerbi.com/t5/Desktop/Dynamic-Column-Calculation-Based-on-Multiple-Slicers/td-p/107480

     

    If so, you can use their answer, but instead of summing the values, you should be able to use something like this:

    MONTHDIFF =  CALCULATE (DATEDIFF(Table1[OrderDate], EARLIEST(Table2[SelectedDate]), month ), ALLSELECTED () )

    Set your slicer to select values from your independant date table, and you should be good to go.

    • thampton's avatar
      thampton
      Helper III

      Cmcmahan Thanks for the reply! For some reason, it is not allowing me to use column in the datediff function; It doesnt pull up the column list. Any ideas?

      • Cmcmahan's avatar
        Cmcmahan
        Resident Rockstar

        What happens when you just type in the column manually?  Do you get an error message?

        I've found that sometimes the autocomplete doesn't fill in, but you can still accomplish the task.