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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Urgent Date interval same column

Hello, guys!

 

I need help to calculate a range of days for combining some of these statuses.

 

As an example:

-ID 8944: The interval between the "new" and "prioritized" must be 6 days;

-ID 8964: The interval between the "new" and "prioritized" must be 3 days;

-ID 8968: The interval between the "new" and "prioritized" must be 2 days;

 

In addition, I must also have the media by work item type:

Feature: (6+3)/2 = 4,5 days

Product Backlog = 2 days

 

Work Item IdWork Item TypeSTATE DATEState
8944Feature01/11/2019Prioritized
8944Feature25/10/2019New
8944Feature30/10/2019Approved
8964Feature12/11/2019In Progress
8964Feature01/11/2019Prioritized
8964Feature28/10/2019New
8964Feature30/10/2019Approved
8968Product Backlog29/10/2019New
8968Product Backlog30/10/2019Approved
8968Product Backlog01/11/2019Prioritized
8968Product Backlog12/11/2019In Progress
1 ACCEPTED SOLUTION

@Anonymous 

If you change the measure to remove the -1 then the datediff will return blank for those with no new or prioritized date but then the number of days don't match what you had in your first post but they do match what you had in your second post.  The -1 was just there to force the calc to match your first post.

Date Diff = 
AVERAGEX(
    VALUES('MEDIAS STATUS'[Work Item Id]),
    (DATEDIFF(
        CALCULATE( MAX ( 'MEDIAS STATUS'[STATE DATE] ), ALLEXCEPT('MEDIAS STATUS','MEDIAS STATUS'[Work Item Id]),'MEDIAS STATUS'[State] = "New"),
        CALCULATE( MAX ( 'MEDIAS STATUS'[STATE DATE] ), ALLEXCEPT('MEDIAS STATUS','MEDIAS STATUS'[Work Item Id]),'MEDIAS STATUS'[State] = "Prioritized"),
        DAY ) )
)

DateDiff2.jpg

 

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

Hello @Anonymous 

I believe this will give you what you are looking for.

 

Date Diff = 
AVERAGEX(
    VALUES(YourTable[Work Item Id]),
    (DATEDIFF(
        CALCULATE( MAX ( YourTable[STATE DATE] ), ALLEXCEPT(YourTable,YourTable[Work Item Id]),YourTable[State] = "New"),
        CALCULATE( MAX ( YourTable[STATE DATE] ), ALLEXCEPT(YourTable,YourTable[Work Item Id]),YourTable[State] = "Prioritized"),
        DAY )-1) )

 

WorkItemType.jpg 

If this solves your issues please mark it as the solution. Kudos 👍 are nice too.

Anonymous
Not applicable

First of all, thank you so much for trying to help me!

 

I noticed that in your solution, if there is no status (new or prioritized), the value "-1" is returned, but I would like it not to be calculated (could return blank).

Also, I noticed that some IDs average are going wrong (8744 must be 2 days instead 1,8737 must be 3 instead 2 days).It seems like it's always returning one day less.

 

MEASURE =
AVERAGEX(
VALUES('MEDIAS STATUS'[Work Item Id]);
(DATEDIFF(
CALCULATE( MAX ( 'MEDIAS STATUS'[STATE DATE] ); ALLEXCEPT('MEDIAS STATUS';'MEDIAS STATUS'[Work Item Id]);'MEDIAS STATUS'[State] = "New");
CALCULATE( MAX ( 'MEDIAS STATUS'[STATE DATE] ); ALLEXCEPT('MEDIAS STATUS';'MEDIAS STATUS'[Work Item Id]);'MEDIAS STATUS'[State] = "Prioritized");
DAY )-1) )

 

Work Item IdWork Item TypeStateSTATE DATEProposed Total
8751FeatureApproved10/10/2019 00:00-1
8751FeaturePrioritized11/10/2019 00:00-1
8751FeatureIn Progress16/10/2019 00:00-1
8751FeatureDone30/10/2019 00:00-1
8744FeatureNew09/10/2019 00:001
8744FeatureApproved10/10/2019 00:001
8744FeaturePrioritized11/10/2019 00:001
8744FeatureIn Progress25/10/2019 00:001
8744FeatureDone30/10/2019 00:001
8742FeatureNew09/10/2019 00:001
8742FeatureApproved10/10/2019 00:001
8742FeaturePrioritized11/10/2019 00:001
8742FeatureIn Progress14/10/2019 00:001
8742FeatureDone30/10/2019 00:001
8737FeatureNew08/10/2019 00:002
8737FeatureApproved10/10/2019 00:002
8737FeaturePrioritized11/10/2019 00:002
8737FeatureIn Progress16/10/2019 00:002
8737FeatureDone30/10/2019 00:002
8725FeatureNew05/10/2019 00:005
8725FeatureApproved10/10/2019 00:005
8725FeaturePrioritized11/10/2019 00:005
8725FeatureIn Progress14/10/2019 00:005
8725FeatureDone29/10/2019 00:005
8359FeatureNew04/09/2019 00:0036
8359FeatureApproved10/10/2019 00:0036
8359FeaturePrioritized11/10/2019 00:0036
8359FeatureIn Progress14/10/2019 00:0036
8359FeatureDone30/10/2019 00:0036
8285FeatureNew23/08/2019 00:00-1
8285FeatureApproved30/08/2019 00:00-1
8285FeatureIn Progress08/09/2019 00:00-1
8285FeatureDone10/10/2019 00:00-1
8280FeatureNew22/08/2019 00:00-1
8280FeatureApproved27/08/2019 00:00-1
8280FeatureIn Progress08/09/2019 00:00-1
8280FeatureDone10/10/2019 00:00-1
7840FeatureNew25/07/2019 00:004
7840FeaturePrioritized30/07/2019 00:004
7840FeatureIn Progress07/08/2019 00:004
7840FeatureDone30/10/2019 00:004
7817FeatureNew25/07/2019 00:004
7817FeaturePrioritized30/07/2019 00:004
7817FeatureIn Progress07/08/2019 00:004
7817FeatureDone29/10/2019 00:004
7707FeatureNew06/07/2019 00:007
7707FeaturePrioritized14/07/2019 00:007
7707FeatureIn Progress23/07/2019 00:007
7707FeatureDone10/10/2019 00:007

@Anonymous 

If you change the measure to remove the -1 then the datediff will return blank for those with no new or prioritized date but then the number of days don't match what you had in your first post but they do match what you had in your second post.  The -1 was just there to force the calc to match your first post.

Date Diff = 
AVERAGEX(
    VALUES('MEDIAS STATUS'[Work Item Id]),
    (DATEDIFF(
        CALCULATE( MAX ( 'MEDIAS STATUS'[STATE DATE] ), ALLEXCEPT('MEDIAS STATUS','MEDIAS STATUS'[Work Item Id]),'MEDIAS STATUS'[State] = "New"),
        CALCULATE( MAX ( 'MEDIAS STATUS'[STATE DATE] ), ALLEXCEPT('MEDIAS STATUS','MEDIAS STATUS'[Work Item Id]),'MEDIAS STATUS'[State] = "Prioritized"),
        DAY ) )
)

DateDiff2.jpg

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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