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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
gclements
Helper II
Helper II

Calculate dates between

Hi,  I have the below measure which calculates the number of days between two dates filtered by the datebetween function.  I only want to show this measure when it falls between the dates provided in DateBetween.  This works until I add the +1, then it provides a value against all dates (see image).  How do I add 1 without breaking the filter?

 

    MEASURE Charge[RentalDaysUsed] =
        CALCULATE (
            DATEDIFF ( [CurrentRentalFromDate], MAX ( Charge[dtChargeDate1] ), DAY ) + 1,
            DATESBETWEEN (
                Charge[dtChargeDate1],
                [CurrentRentalFromDate],
                MAX ( Charge[dtChargeDate1] )
            )
        )

Untitled.png

1 ACCEPTED SOLUTION
gclements
Helper II
Helper II

Thansk for the reply but I fixed this by adding a FILTER instead of the DATESBETWEEN:

CALCULATE (
DATEDIFF ( MAX ( Charge[Charge Date 1] ), [Current Rental To Date], DAY ),
FILTER(Charge, Charge[Charge Date 1] >= [Current Rental From Date])
)

View solution in original post

2 REPLIES 2
gclements
Helper II
Helper II

Thansk for the reply but I fixed this by adding a FILTER instead of the DATESBETWEEN:

CALCULATE (
DATEDIFF ( MAX ( Charge[Charge Date 1] ), [Current Rental To Date], DAY ),
FILTER(Charge, Charge[Charge Date 1] >= [Current Rental From Date])
)
BA_Pete
Super User
Super User

Hi @gclements ,

 

You could try something like this:

Charge[RentalDaysUsed] =
VAR __daysUsed =
CALCULATE(
  DATEDIFF(
    [CurrentRentalFromDate],
    MAX(Charge[dtChargeDate1]),
    DAY
  ),
  DATESBETWEEN(
    Charge[dtChargeDate1],
    [CurrentRentalFromDate],
    MAX(Charge[dtChargeDate1])
  )
)
RETURN
SWITCH(
  TRUE(),
  ISBLANK(__daysUsed), BLANK(),
  __daysUsed + 1
)

 

Not the most elegant solution, but should get you over the line.

 

Pete 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors