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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
santoshfx
Regular Visitor

Need help on Dax formula

I have 3 tables Requests, Users, Teams
- I want to find the working days between a Request ID with a Status as New (Created Date) and same Request ID immediate subsequent status (Reported Date)
- so [No of days] formula should be = Networkdays(Created Date, Reported Date)
- in the output Assignee and Priority should be populated from Subsequent status record.

- Finally  I want to create a chart which team wise avg no of days taken for each priority

 

Request

IDRequest IDCreated DateReported DateStatus TxnIDAssigneePriority
110001-06-202505-06-2025New1abcLow
210001-06-202510-06-2025Assigned 2pqrLow
310001-06-202511-06-2025In Progress3pqrLow
410001-06-202512-06-2025Closed4pqrLow
610105-06-202512-06-2025New8abcHigh
710105-06-202516-06-2025Open2abcLow
810105-06-202517-06-2025Closed10abcLow
910206-06-202517-06-2025New14xyzHigh
1010206-06-202522-06-2025Closed16xyzHigh

 

Users

IDusernameteam_id
1abc1
2pqr1
3xyz2

 

Teams

IDTeamName
1Team 1
2Team 2

 

Output

Request IDNo of DaysAssigneePriorityTeam
1007pqrLowTeam 1
1018abcHighTeam 1
10211xyzHighTeam 2

 

Dax formula tried

Output Table =
SUMMARIZECOLUMNS (
    'Requests'[Request ID],
    "No of Days",
        VAR _createdDate =
            CALCULATE (
                MIN ( 'Requests'[Created Date] ),
                ALLEXCEPT ( 'Requests', 'Requests'[Request ID] )
            )
        VAR _reportedDate =
            CALCULATE (
                MAXX ( 'Requests', 'Requests'[Reported Date] ),
                ALLEXCEPT ( 'Requests', 'Requests'[Request ID] )
            )
        RETURN
            DATEDIFF ( _createdDate, _reportedDate, DAY ),
    "Assignee",
        VAR _latestTxnId =
            CALCULATE (
                MAXX (
                    FILTER (
                        ALLEXCEPT ( 'Requests', 'Requests'[Request ID] ),
                        'Requests'[Reported Date] = CALCULATE ( MAXX ( 'Requests', 'Requests'[Reported Date] ), ALLEXCEPT ( 'Requests', 'Requests'[Request ID] ) )
                    ),
                    'Requests'[TxnId]
                )
            )
        RETURN
            LOOKUPVALUE ( 'Requests'[Assignee], 'Requests'[TxnId], _latestTxnId ),
    "Priority",
        VAR _latestTxnId =
            CALCULATE (
                MAXX (
                    FILTER (
                        ALLEXCEPT ( 'Requests', 'Requests'[Request ID] ),
                        'Requests'[Reported Date] = CALCULATE ( MAXX ( 'Requests', 'Requests'[Reported Date] ), ALLEXCEPT ( 'Requests', 'Requests'[Request ID] ) )
                    ),
                    'Requests'[TxnId]
                )
            )
        RETURN
            LOOKUPVALUE ( 'Requests'[Priority], 'Requests'[TxnId], _latestTxnId ),
    "Team",
        VAR _latestTxnId =
            CALCULATE (
                MAXX (
                    FILTER (
                        ALLEXCEPT ( 'Requests', 'Requests'[Request ID] ),
                        'Requests'[Reported Date] = CALCULATE ( MAXX ( 'Requests', 'Requests'[Reported Date] ), ALLEXCEPT ( 'Requests', 'Requests'[Request ID] ) )
                    ),
                    'Requests'[TxnId]
                )
            )
        VAR _finalAssignee =
            LOOKUPVALUE ( 'Requests'[Assignee], 'Requests'[TxnId], _latestTxnId )
        RETURN
            LOOKUPVALUE (
                Teams[TeamName],
                Teams[ID], LOOKUPVALUE (
                    Users[team_id],
                    Users[username], _finalAssignee
                )
            )
)

 

 

 

 

1 ACCEPTED SOLUTION
v-kpoloju-msft
Community Support
Community Support

Hi @santoshfx,

Thank you for reaching out to the Microsoft fabric community forum.  I reproduced the scenario again, and it worked on my end. I used my sample data and successfully implemented it.

outcome:

vkpolojumsft_0-1750763663875.png
For 101, the immediate subsequent row will be with ID 8. This is why the priority is set to low.

I am also including .pbix file for your better understanding, please have a look into it:

If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

Thank you for using Microsoft Community Forum.

View solution in original post

7 REPLIES 7
Poojara_D12
Super User
Super User

Hi @santoshfx 

You're working on analyzing the turnaround time of requests in Power BI, specifically measuring how long it takes from when a request is created with a "New" status to when it moves to the next status. Your dataset includes multiple records for the same Request ID, each representing a different status change over time, with associated dates, assignees, and priorities. You want to calculate the number of working days (excluding weekends) between the "New" status and its immediate next status, and then capture the Assignee, Priority, and corresponding Team from that next status record. To visualize this, you plan to create a chart that shows the average number of working days taken by each team, broken down by request Priority.

 

To achieve this, you've written a complex DAX measure using SUMMARIZECOLUMNS and variables that try to identify the earliest and latest reported dates for each request. However, your logic currently fetches the latest status record, not necessarily the immediate one following "New", which skews the working days calculation. Also, your use of DATEDIFF counts total calendar days instead of working days, so it's not accurately reflecting business time. Furthermore, the values for Assignee, Priority, and Team are pulled from the wrong status update because they're linked to the record with the maximum Reported Date, not the next one after "New". For this scenario to be accurate, you need to explicitly identify the "New" status record and then find the one with the next highest TxnID or Reported Date for the same Request ID, and use these two rows to calculate the number of working days (using a working calendar). This will allow you to create a reliable summary table, which you can then use in your chart to display team-wise performance on request handling across different priorities.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
v-kpoloju-msft
Community Support
Community Support

Hi @santoshfx,

Thank you for reaching out to the Microsoft fabric community forum.  I reproduced the scenario again, and it worked on my end. I used my sample data and successfully implemented it.

outcome:

vkpolojumsft_0-1750763663875.png
For 101, the immediate subsequent row will be with ID 8. This is why the priority is set to low.

I am also including .pbix file for your better understanding, please have a look into it:

If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

Thank you for using Microsoft Community Forum.

Hi @santoshfx,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

Hi @santoshfx,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

Hi @santoshfx,

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.

lbendlin
Super User
Super User

Please provide more details.  What do you consider working days and do you have a holiday list?

What should happen when assignees change?  Show first or last one?

What should happen when the priority changes?  Show highest one or last one?

When a new request is created it has Status as New
Later on it can have any other status like (Assigned, In Progress, Open, Closed, Rejected) and there is no sequence

No of working days should be calculated based on Created Date when the status was New and the Date reported when status first got changed.

In the output, I want to see Request ID, No of Days.
Additionally, Assignee, Priority & Team (details from changed record)

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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