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

Calculated field from nested dataset challenge!

Hi,

 

I'm stuggling - need some guidance!

 

I am trying to map our helpdesk ticket data into the sankey visuals.

 

Out ticket data shows how tickets are moved from one engineer to the next and is a simplified structureed looks like this:

 

TicketIDDateUser
INC000101/01/2019 09:00John
INC000303/01/2019 09:35Matt
INC000101/01/2019 12:10Phil
INC000504/01/2019 09:00John
INC000303/01/2019 14:00Phil
INC000605/01/2019 13:00John
INC000606/01/2019 11:05Matt
INC000304/01/2019 09:10John

 

For instance, the above example shows INC001 starts with John, then Phil.

 

I am trying to map the ticket flows within a Sankey report which wants the data like this:-

 

TicketIDSourceDestination
INC0001JohnPhil
INC0003MattPhil
INC0003PhilJohn
INC0006JohnMatt

 

I've been trying to FILTER matching the ticketID but I cant work out how to ensure it is working cronologically through the dates.

 

Help!!

 

Gavin.

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi @grussell ,

this can be handled both with DAX and M(power query). My M-skills are not the best, so I can show the DAX-version

Using you the sample data you provided, I create a calculated column to get an index grouped per ticketID

IndexGroupedByTicketID =
VAR _ticket = 'Table'[TicketID]
VAR _date = 'Table'[Date]
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' );
        FILTER (
            ALL ( 'Table' );
            'Table'[TicketID] = _ticket
                && 'Table'[Date] <= _date
        )
    )

Using this column to find the next person to handle the ticket

NextUser =
VAR _ind = 'Table'[IndexGroupedByTicketID] + 1
VAR _ticket = 'Table'[TicketID]
RETURN
    CALCULATE (
        MIN ( 'Table'[User] );
        FILTER (
            ALL ( 'Table' );
            'Table'[IndexGroupedByTicketID] = _ind
                && 'Table'[TicketID] = _ticket
        )
    )


In the sankey chart, put user in the source field and nextUser in the destination field

Depending on the size of your dataset and you source, there is possibly some performance to gain by doing this in power query. The principle is the same for doing it in power query, here is a link to how to build a similar index in power query

 

cheers,

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

You may refer to my solution here - Rearrange travel data to clearly show travel from and travel to locations.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
sturlaws
Resident Rockstar
Resident Rockstar

Hi @grussell ,

this can be handled both with DAX and M(power query). My M-skills are not the best, so I can show the DAX-version

Using you the sample data you provided, I create a calculated column to get an index grouped per ticketID

IndexGroupedByTicketID =
VAR _ticket = 'Table'[TicketID]
VAR _date = 'Table'[Date]
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' );
        FILTER (
            ALL ( 'Table' );
            'Table'[TicketID] = _ticket
                && 'Table'[Date] <= _date
        )
    )

Using this column to find the next person to handle the ticket

NextUser =
VAR _ind = 'Table'[IndexGroupedByTicketID] + 1
VAR _ticket = 'Table'[TicketID]
RETURN
    CALCULATE (
        MIN ( 'Table'[User] );
        FILTER (
            ALL ( 'Table' );
            'Table'[IndexGroupedByTicketID] = _ind
                && 'Table'[TicketID] = _ticket
        )
    )


In the sankey chart, put user in the source field and nextUser in the destination field

Depending on the size of your dataset and you source, there is possibly some performance to gain by doing this in power query. The principle is the same for doing it in power query, here is a link to how to build a similar index in power query

 

cheers,

Thanks - worked a treat. I noticed the semi-colon didn't work but changed these to commas and it was fine. Thanks again.

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.