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
santoshfx
New Member

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
                )
            )
)

 

 

 

 

3 REPLIES 3
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.

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
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.