Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

How can I make this calculated column dynamic with multiple slicers?

 

 

Hi

 

I use this calculated column to calculate days between entries. I want to calculate days between when there are multiple slicers.  It works with the ID slicers but not anything else. Any ideas?

 

With ID slicer works fine

Does not work with my category slicer
 
Days Between =
VAR temp =
    TOPN (
        1,
FILTER (
            'Time Stamp',
            'Time Stamp'[ID] = EARLIER ( 'Time Stamp'[ID] )
                && 'Time Stamp'[Occurrence] < EARLIER ( 'Time Stamp'[Occurrence] )
        ),
        [Occurrence], DESC
    )
RETURN
    DATEDIFF ( MINX ( temp, [Occurrence] ), 'Time Stamp'[Occurrence], DAY )
 
Thanks

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Calculated columns are only updated when you refresh the dataset. You would need (and probably should anyway) covert this to a measure. 

    • Anonymous's avatar
      Anonymous
      Not applicable

       

       

      The reason I used a calculated column is because I would always get an error with the measure using the exact same DAX.



       

      • Anonymous's avatar
        Anonymous
        Not applicable

        The concept of earlier doesnt exists if you take your calculated column logic and directly apply to a measure. You can use earlier in a measure with some additiona logic, but probably easier to just add an index to your table so you have a concept of what is previous. You can do that using a calculated column, or better yet power query. can you upload some sample data?