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
RonaldvdH
Post Patron
Post Patron

Formula based on dates

Hey guys,

 

I need your help again and this time i need an adjustment of my formula i think.

The question is actually pretty simple but my excisting formula doesn't seem to work.

 

I have a table with our permits in them with different dates and i want a visual that triggers us if a permit expires within 6 weeks.

So i have a colum whicht has the dates on which an permit expires and i want another column to show the date when we need to extend the permit

                

                 

Permit                                    expires onextend per
Permit A30-06-2019-05-20
Permit B  30-09-2019-08-20
Permit C30-08-2019-07-20
Permit D30-12-2018-11-20

 

The trick is that i only want the permits to show where the extend per date is within 6 week from now so i made this formula but it doesn't produce the right result

 

Extend permit = IF(Permits[Permits expires]<>BLANK(),IF(Permits[Permits expires]<(TODAY()-42),Permits[Permits expires]-42))

 

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @RonaldvdH ,

 

We can create a calculate column to meet your requirement.

 

Extend permit = 
IF(
    'Permits'[expires on]<>BLANK(),
    IF (
        AND (
        Permits[expires on] >= TODAY(),
        Permits[expires on] <= TODAY() + 42
        ),
        Permits[expires on] - 42
        )
    )

 

You can change the date range according to your requirement. The result like this,

 

Formula 1.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

4 REPLIES 4
v-zhenbw-msft
Community Support
Community Support

Hi @RonaldvdH ,

 

We can create a calculate column to meet your requirement.

 

Extend permit = 
IF(
    'Permits'[expires on]<>BLANK(),
    IF (
        AND (
        Permits[expires on] >= TODAY(),
        Permits[expires on] <= TODAY() + 42
        ),
        Permits[expires on] - 42
        )
    )

 

You can change the date range according to your requirement. The result like this,

 

Formula 1.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

@RonaldvdH , Create a measure like this and use it. This should filter

calculate(countrows(Permits),filter(Permits,Permits[Permits expires]<>BLANK() && Permits[Permits expires]<(TODAY()-42)))

@amitchandak i need a calculated column to use in the visual so if your measure can be adjusted it might work

your formula now just counts the number of rows where the formula returns a value instead of a value per row in the database

mahoneypat
Employee
Employee

Try this expression instead

 

Extend permit =
VAR __thisdate =
TODAY ()
RETURN
IF (
AND (
Permits[Permits expires] >= __thisdate - 42,
Permits[Permits expires] <= __thisdate
),
Permits[Permits expire] - 42
)
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.