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
Juleeees
Frequent Visitor

Changing a date formula with a visual filter

Hi, 

 

I want to change this formular by a visual filter: 

 

Difference Days to Overdue = IF([Progress] = "Finished", BLANK(),DATEDIFF([Due Date (DD/MM/YYYY)], MIN('Calendar'[Date]) ,DAY))
 
The one marked in red should be a selectable value from the created table Calendar. I want a visual filter where you can select a certain range and then the minimum of this range is selected.
 
When I currently insert a visual filter of Calendar[Date] into my report page, the formula does not filter with.
 
Thanks in Advantage.
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Juleeees ,

What you are trying to create is a calculated column? If what you created is a calculated column, it will not change according to the user interaction(slicer, filter, column selections etc.) in the report as the value of a calculated column is computed during data refresh and uses the current row as a context... Please review the following links about the difference of calculated column and measure...

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

 

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a slicer using [Date] field of 'Calendar' table

2. Create a measure as below to get the dynamic Difference Days by the filter/slicer...

Difference Days to Overdue = 
IF (
    SELECTEDVALUE ( 'Table'[Progress] ) = "Finished",
    BLANK (),
    DATEDIFF (
        SELECTEDVALUE ('Table'[Due Date (DD/MM/YYYY)] ),
        MIN ( 'Calendar'[Date] ),
        DAY
    )
)

yingyinr_1-1673599217802.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Juleeees ,

What you are trying to create is a calculated column? If what you created is a calculated column, it will not change according to the user interaction(slicer, filter, column selections etc.) in the report as the value of a calculated column is computed during data refresh and uses the current row as a context... Please review the following links about the difference of calculated column and measure...

Calculated Columns and Measures in DAX

Calculated Columns vs Measures

 

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create a slicer using [Date] field of 'Calendar' table

2. Create a measure as below to get the dynamic Difference Days by the filter/slicer...

Difference Days to Overdue = 
IF (
    SELECTEDVALUE ( 'Table'[Progress] ) = "Finished",
    BLANK (),
    DATEDIFF (
        SELECTEDVALUE ('Table'[Due Date (DD/MM/YYYY)] ),
        MIN ( 'Calendar'[Date] ),
        DAY
    )
)

yingyinr_1-1673599217802.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Juleeees , Then you have create a measure

 

example

 

Difference Days to Overdue = Sumx(Table, IF([Progress] = "Finished", BLANK(),DATEDIFF([Due Date (DD/MM/YYYY)], MIN('Calendar'[Date]) ,DAY)) )

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.

Top Solution Authors