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
Elisa112
Helper V
Helper V

Difference in dates for different meetings in DAX

I have created a matrix visual to show the difference in dates for various type of appointments.  The appointments are introduction/Assess/ stored in Meeting Type so the matrix looks like this:

 

UserID           Introduction     Assess                  DateDifferene

123000          12/01/2023      15/01/2023                        ?

15689             21/01/2023      24/01/2023                       ?

 

I am trying to find the date difference between Introduction and Assess. the matrix is set up as

Rows = userID

Columns = Type

Values = EarliestDate (Meeting[Date/time]).

 

I need to create a measure for the date difference, the dates are stored in Meeting[Date/Time]).

Thank you 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Elisa112,

Current power bi does not support use measure formula on the axis field or work as category. (you can't use it on row or column field of matrix) They require the category to expand the row contents and calculation ranges or they will only return single value.

Did you means the 'Introduction', 'Assess' are measure expmreison that used on the matrix value field? If that is the case, you can try to use the summarize function of simulation current calculation group and row contents of the expression, then you can add custom field to calculate the diff:

formula =
VAR summary =
    ADDCOLUMNS (
        SUMMARIZE (
            ALLSELECTED ( Table1 ),
            [UserID],
            "_Introduction", [Introduction],
            "_Assess", [Assess]
        ),
        "Diff", DATEDIFF ( [_Introduction], [_Assess], DAY )
    )
RETURN
    SUMX ( summary, [Diff] )

Regards,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

HI @Elisa112,

Did you means the expression are used to calculate with static type values? If that is the case, you can try to use the following measure formula if it suitable for your requirement.

formula =
VAR intro =
    CALCULATE (
        MIN ( Table1[Date] ),
        FILTER ( ALLSELECTED ( Table1 ), [Type] = "Introduction" ),
        VALUES ( Table1[UserID] )
    )
VAR asse =
    CALCULATE (
        MAX ( Table1[Date] ),
        FILTER ( ALLSELECTED ( Table1 ), [Type] = "Assess" ),
        VALUES ( Table1[UserID] )
    )
RETURN
    DATEDIFF ( intro, asse, DAY )

If you mean these results will apply to calculate with dynamic rolling between different type of values, it should difficulty than calculate on specific values.

I'd like to suggest you to add an index filed of the type filed values, then you can use the current index to find out current type and previous type to get difference.

Regards,
Xiaoxin Sheng

Thank you, the two dates are static, we use the earliest attended date for each type of meeting and then we need to compare the two to make sure we hit the KPI (less than 5 days).  I will try use solution, the problem I have is now bringing the measure into the maxtrix visual. brinking it into the column does not work.  any Suggestions? 

Anonymous
Not applicable

HI @Elisa112,

Current power bi does not support use measure formula on the axis field or work as category. (you can't use it on row or column field of matrix) They require the category to expand the row contents and calculation ranges or they will only return single value.

Did you means the 'Introduction', 'Assess' are measure expmreison that used on the matrix value field? If that is the case, you can try to use the summarize function of simulation current calculation group and row contents of the expression, then you can add custom field to calculate the diff:

formula =
VAR summary =
    ADDCOLUMNS (
        SUMMARIZE (
            ALLSELECTED ( Table1 ),
            [UserID],
            "_Introduction", [Introduction],
            "_Assess", [Assess]
        ),
        "Diff", DATEDIFF ( [_Introduction], [_Assess], DAY )
    )
RETURN
    SUMX ( summary, [Diff] )

Regards,

Xiaoxin Sheng

saurabhtd
Resolver II
Resolver II

@Elisa112 Here is the DAX logic for a measure which might work in your case.  

DateDifference = 
VAR IntroductionDate = CALCULATE(MIN(Meeting[Date/Time]), Meeting[Type] = "Introduction")
VAR AssessDate = CALCULATE(MIN(Meeting[Date/Time]), Meeting[Type] = "Assess")
RETURN
    DATEDIFF(IntroductionDate, AssessDate, DAY)

 

Thank you, I am trying your solution and think it will work, problem is bringing the measure date difference into the matrix, adding the measure as a row/colum or value does not work.  any suggestions? 

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.