Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PA7177
Helper II
Helper II

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 fineWith ID slicer works fine

Does not work with my category slicerDoes 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 4
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. 

snip3.PNG

 

 

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



 

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?

This is what my data looks like.

 

Sliced by ID without category slicerSliced by ID without category slicerSliced by ID with category slicer. Does not count days properly.Sliced by ID with category slicer. Does not count days properly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.