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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
ArchStanton
Power Participant
Power Participant

DAX code issue

When the Application Validation Date and the Resolution Date are the same then the following code shows a Zero but I would like it to show 1 day:

Case Length (Validation Date) = If ('Cases'[statecode] = "Active", 
                        DATEDIFF('Cases'[applicationvalidationdate], NOW(), DAY),
                        DATEDIFF('Cases'[applicationvalidationdate],
                        'Cases'[Resolution Date], DAY))


I've had a few attempts but can't seem to figure this one out.

 

 

1 ACCEPTED SOLUTION
oussamahaimoud
Memorable Member
Memorable Member

Hi,

 

The issue is with how DATEDIFF works, it counts the number of day boundaries crossed, not an inclusive day count. So when your Validation Date and Resolution Date fall on the same day, there's no boundary crossed yet, and you get 0.

Try adding +1 to each branch:

 

Case Length (Validation Date) = 

IF('Cases'[statecode] = "Active",

    DATEDIFF('Cases'[applicationvalidationdate], NOW(), DAY) + 1,

    DATEDIFF('Cases'[applicationvalidationdate], 'Cases'[Resolution Date], DAY) + 1

)

 

This turns same-day cases into 1, which is what you're after. Just double check with your team whether all your other date ranges should also be counted inclusively (start day + end day both counted) - this +1 will apply that logic consistently across the board, not just for the same-day scenario.


  Did my response help you? Clicking Kudos is a small gesture that goes a long way, it encourages contributors and helps the community thrive!


Did I answer your question? Please mark my post as a Solution, it helps others find the answer faster.


Senior Data & BI Consultant · Microsoft Fabric & Power BI Specialist


Connect with me on LinkedIn

View solution in original post

6 REPLIES 6
Rupa01
Impactful Individual
Impactful Individual

Hi @ArchStanton,

Checkout below DAX Calculated column - this calculation checks applicationvalidationdate and Resolution Date if they fall on the same day, if so then it adds 1 day. Also, it checks if applicationvalidationdate is today and its still active then it also shows as 1 day.

Case Length (Validation Date) = 
VAR StartDate = 'Cases'[applicationvalidationdate]
VAR EndDate = 
IF(
    'Cases'[statecode] = "Active",
     IF(
        'Cases'[applicationvalidationdate] = TODAY(),
        TODAY() + 1,
        TODAY()
     ),
    IF(
        'Cases'[applicationvalidationdate] = 'Cases'[Resolution Date], 
        'Cases'[Resolution Date] + 1, 
        'Cases'[Resolution Date]
    )
)
RETURN
DATEDIFF(StartDate, EndDate, DAY)

Rupa01_0-1784095453306.png

 

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer
Rupa01
Impactful Individual
Impactful Individual

@ArchStanton If you want inclusive of end date in all the scenarious not only when both dates fall on same day, use below measure - 

Case Length (Validation Date) = 
IF(
    'Cases'[statecode] = "Active",
    DATEDIFF('Cases'[applicationvalidationdate], NOW(), DAY) + 1,
    DATEDIFF('Cases'[applicationvalidationdate], 'Cases'[Resolution Date], DAY) + 1
)

Rupa01_1-1784095806115.png

 

💡 Helpful? Give a Kudos 👍 — keep the community growing
 Solved your issue? Mark as Solution ✔️ — help others find it faster

Best regards,
Rupasree Achari | BI & Fabric Analytics Engineer
divyed
Super User
Super User

Hello @ArchStanton ,

 

You can try below dax :

 

Case Length (Validation Date) =
IF (
'Cases'[statecode] = "Active",
DATEDIFF('Cases'[applicationvalidationdate], NOW(), DAY) + 1,
DATEDIFF('Cases'[applicationvalidationdate], 'Cases'[Resolution Date], DAY) + 1
)

 

If your date columns also contain timestmps (hours, minutes), Datediff compares just the dates. However, if you notice fractional differences or want to ensure it strictly check the calendar date, wrapping the dates in INT() or DATEVALUE() can be a workaround.

 

I hope this helps.

 

Did I answer your query ? Mark this as solution if this has solved your issue, kudos are appreciated.

 

Cheers

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/
ryan_mayu
Super User
Super User

@ArchStanton 

you can try this

 

Case Length (Validation Date) =
VAR StartDate =
'Cases'[applicationvalidationdate]

VAR EndDate =
IF (
'Cases'[statecode] = "Active",
NOW(),
'Cases'[Resolution Date]
)

RETURN
IF (
ISBLANK ( StartDate ) || ISBLANK ( EndDate ),
BLANK (),
DATEDIFF ( StartDate, EndDate, DAY ) + 1
)

 

if this does not work, pls provide some sample data and expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




oussamahaimoud
Memorable Member
Memorable Member

Hi,

 

The issue is with how DATEDIFF works, it counts the number of day boundaries crossed, not an inclusive day count. So when your Validation Date and Resolution Date fall on the same day, there's no boundary crossed yet, and you get 0.

Try adding +1 to each branch:

 

Case Length (Validation Date) = 

IF('Cases'[statecode] = "Active",

    DATEDIFF('Cases'[applicationvalidationdate], NOW(), DAY) + 1,

    DATEDIFF('Cases'[applicationvalidationdate], 'Cases'[Resolution Date], DAY) + 1

)

 

This turns same-day cases into 1, which is what you're after. Just double check with your team whether all your other date ranges should also be counted inclusively (start day + end day both counted) - this +1 will apply that logic consistently across the board, not just for the same-day scenario.


  Did my response help you? Clicking Kudos is a small gesture that goes a long way, it encourages contributors and helps the community thrive!


Did I answer your question? Please mark my post as a Solution, it helps others find the answer faster.


Senior Data & BI Consultant · Microsoft Fabric & Power BI Specialist


Connect with me on LinkedIn

Thank you for this, its so obvious now which is frustrating!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors