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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jalaomar
Helper IV
Helper IV

Calculating number of days between two dates

Hello,

 

I am wondering if you could support me in how you can create a dax measure so that I can calculate the days between two different dates.

 

Below you can view the Matrix table, where I have one column Baseline including "Contract" and "ActualSchedule" baselines and another column with the different Tollgates phases (ITG0, ITG0.1 etc.) 

 

and I would like to add the measure in the Matrix table to display the dates difference between the two dates.

 

To display the date values in the Matrix table, I am using the following measure (in case it's needed)

Date Value = maxx(TollgateDataset, coalesce(TollgateDataset[ActualStart],TollgateDataset[ScheduleStart]))

jalaomar_0-1654252359557.png

 

Thanks!

 

BR

J

 

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @jalaomar ;

Is your problem solved? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.


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

v-yalanwu-msft
Community Support
Community Support

Hi, @jalaomar ;

Try it.

Date Value =
DATEDIFF (
    MAX ( TollgateDataset[ActualStart] ),
    MAX ( TollgateDataset[ScheduleStart] ),
    DAY
)

 If not right, can you share a simple example of data removal for sensitive information to understand the composition of your data model? and the output what you want.


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

tamerj1
Super User
Super User

Hi @jalaomar 

please ise this measure instead and activate the row totals

Date Value New =
VAR NormalValue = [Date Value]
VAR ContractValue =
    CALCULATE ( [Date Value], TollgateDataset[Baseline] = "Contract" )
VAR ActualScheduleValue =
    CALCULATE ( [Date Value], TollgateDataset[Baseline] = "ActualSchedule" )
RETURN
    IF (
        HASONEVALUE ( TollgateDataset[Baseline] ),
        NormalValue,
        ContractValue - ContractValue
    )

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors