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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
alanphamvistra4
Frequent Visitor

PQL Equation to Find Difference between Dates is Returning both Positive and Negative Values

I have the follwing Custom Column Equation:

if [Overall Status] = "Submitted for Review" then DateTime.LocalNow() - [Submit Date] else [Review Date] - [Submit Date])

 

All of the Submit Dates are in the past, so I should get only positive values or 0. Some of the records are returning negative values even when the Submit Date is years in the past. How can I fix it to only return postive values?

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

Hi @alanphamvistra4 ,

You can create a calculated column as below to get it, please find the details in the attachment.

Difference = 
VAR _days =
    IF (
        'Table'[Overall Status] = "Submitted for Review",
        DATEDIFF ( 'Table'[Submit Date], TODAY (), DAY ),
        DATEDIFF ( 'Table'[Submit Date], 'Table'[Review Date], DAY )
    )
RETURN
    IF ( _days < 0, BLANK (), _days )

yingyinr_0-1674196912230.png

 

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

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

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @alanphamvistra4 ,

You can create a calculated column as below to get it, please find the details in the attachment.

Difference = 
VAR _days =
    IF (
        'Table'[Overall Status] = "Submitted for Review",
        DATEDIFF ( 'Table'[Submit Date], TODAY (), DAY ),
        DATEDIFF ( 'Table'[Submit Date], 'Table'[Review Date], DAY )
    )
RETURN
    IF ( _days < 0, BLANK (), _days )

yingyinr_0-1674196912230.png

 

If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

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.

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors