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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
cindymei_chiu
Frequent Visitor

Using filter with DateDiff

Hi All, 

I'm new to pbi and need help with the following table to calculate the right data:

cindymei_chiu_0-1749222450991.png

I want to calculate the datediff using actual end date from exit meeting to the actual end date on final audit report, and calculate if the date difference is within 5 business days, like the table below in excel:

 

cindymei_chiu_1-1749222889032.png

I only managed to get this matrix in pbi and got stuck using DAX:

cindymei_chiu_2-1749223022319.png

Any help would be much appreciated!!

Thank you!

1 ACCEPTED SOLUTION

Hi @cindymei_chiu,

 

Try this measure using CALCULATE Function 

VAR ExitDate =
    CALCULATE(
        MAX('ProjectPhaseMilestones'[ActualEndDate]),
        'ProjectPhaseMilestones'[MilestonesName] = "Exit Meeting"
    )

VAR FinalAuditDate =
    CALCULATE(
        MAX('ProjectPhaseMilestones'[ActualEndDate]),
        'ProjectPhaseMilestones'[MilestonesName] = "Final Audit Report"
    )

 

Regards,

Vinay Pabbu

View solution in original post

11 REPLIES 11
johnt75
Super User
Super User

Presuming that you have an ID column to match the two rows together you could create a measure like

Within 5 business days =
VAR CurrentID =
    SELECTEDVALUE ( 'Table'[ID] )
VAR ExitMeeting =
    LOOKUPVALUE (
        'Table'[Actual End Date],
        'Table'[ID], CurrentID,
        'Table'[Milestone Name], "Exit Meeting"
    )
VAR FinalAudit =
    LOOKUPVALUE (
        'Table'[Actual End Date],
        'Table'[ID], CurrentID,
        'Table'[Milestone Name], "Final Audit Report"
    )
VAR Result =
    IF ( NETWORKDAYS ( ExitMeeting, FinalAudit ) <= 5, "Yes", "No" )
RETURN
    Resul
v-vpabbu
Community Support
Community Support

Hi @cindymei_chiu,

 

Thank you for reaching out to Microsoft Fabric Community Forum.

 

Create a calculated column using below DAX Expression.

Within5BusinessDays = 
VAR StartDate = 'Sheet1'[Exit Meeting]
VAR EndDate = 'Sheet1'[Final Audit Report]
VAR BusinessDays =
    CALCULATE(
        COUNTROWS(
            FILTER(
                ADDCOLUMNS(
                    CALENDAR(StartDate, EndDate),
                    "Weekday", WEEKDAY([Date], 2)
                ),
                [Weekday] <= 5
            )
        )
    )
RETURN IF(BusinessDays <= 5, "Yes", "No")

 

Result

vvpabbu_0-1749453578653.png

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!


Regards,
Vinay Pabbu

 

Thank you so much!  Do I need to specific the column names or filter:

VAR StartDate = 'ProjectPhaseMilestones'[MilestonesName = "Exit Meeting"]
VAR EndDate = 'ProjectPhaseMilestones'[MilestonesName = "Final Audit Report"]
If without, both gave me the same error message that Exit Meeting and Final Audit Report cannot be found.  
 
I'm using both ActualEndDate for MilestoneName = "Exit Meeting" and "Final Audit Report":
 cindymei_chiu_0-1749478072752.png

Greatly appreciate your help!!

 

Hi @cindymei_chiu,

 

DAX doesn’t allow filtering like that directly in a column reference. Instead, you need to filter the table and extract the value from the ActualEndDate column where MilestonesName = "Exit Meeting".

 

Regards,

Vinay Pabbu

Hi Vinay, 

How do I do that?  Filter the table and extract the value from the ActualEndDate column where MilestonesName = "Exit Meeting" and "Final Audit Report".  

Thank you!

Hi @cindymei_chiu,

 

Try this measure using CALCULATE Function 

VAR ExitDate =
    CALCULATE(
        MAX('ProjectPhaseMilestones'[ActualEndDate]),
        'ProjectPhaseMilestones'[MilestonesName] = "Exit Meeting"
    )

VAR FinalAuditDate =
    CALCULATE(
        MAX('ProjectPhaseMilestones'[ActualEndDate]),
        'ProjectPhaseMilestones'[MilestonesName] = "Final Audit Report"
    )

 

Regards,

Vinay Pabbu

That works!!  Thank you so much!!!

cindymei_chiu
Frequent Visitor

The pbix table is included in the first screen view and my expected result is the excel in the second screen view.  Thank you!

The question makes some confuesion that's why I am asking .pbix file

Sorry for any confusion. My table has a milestonenames which includes annoucemene letter, exit meeting, final audit report and finalization.    The actual end date is in another column.  I want to pull in and compare the actual end date for exit meeting and final audit report, and to calculate if these 2 dates are within 5 business days.  I can easily do this in excel but since my other tables are in pbix, i want to see if i can create the same in it.  Thanks for your help! 

ajaybabuinturi
Solution Sage
Solution Sage

Hi @cindymei_chiu

Could you please share sample data of .pbix file and expected result mockup

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.