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

Finding top 3 averages across range of journeys with specific end locations

OK, slightly complex query and I'm a complete PowerBI newbie, so not great with this!

 

I have source data as follows:

 

Start Location    End Location    Time

A                        H                      00:01

B                        J                       02:00

C                        I                       03:03

D                        Z                      01:01

B                       I                        02:00

 

 

The start and end locations are specifc unique locations (different lists from each other - we have a scenario where devices travel from a pool of locations to a different pool of locations).

 

I have approx 100,000 rows of this data, all based on captured data.

 

I am trying to get a table that would give me the following:

 

End Location (unique list)                  Quickest average start location  (Time)                2nd quickest average start location  (Time)          3rd...

 

I also need to exclude the quickest, 2nd quickest and 3rd quickest if they only had 2 entries or less as outliers.

 

I cant work out where to start! Any suggestions greatly appreciated.

 

 

 

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @sclennell,

 

If I understand you correctly, you should be able to follow steps below to get your expected result.

 

I assume your called is "Table1".

 

1. Use the formula below to create a new table with each End Location and distinct Time values.

 

New Table = 
SUMMARIZE (
    Table1,
    Table1[Start Location],
    Table1[End Location],
    "Averate Time", AVERAGE ( Table1[Time] )
)

 

2. Use the formula below to add a calculate column to the new created table to Rank Time values for each End Location.

 

Rank = 
VAR t = 'New Table'[Averate Time]
VAR endL = 'New Table'[End Location]
RETURN
    CALCULATE (
        RANK.EQ ( t, 'New Table'[Averate Time], ASC ),
        FILTER ( ALL ( 'New Table' ), 'New Table'[End Location] = endL )
    )

 

3. Then should be able to use the formula below to create a new table with End Location (unique list), Quickest average start location  (Time), 2nd quickest average start location  (Time), 3rd...

 

Final Table = 
SUMMARIZE (
    'New Table',
    'New Table'[End Location],
    "Quickest average start location", CALCULATE ( FIRSTNONBLANK('New Table'[Start Location],1), 'New Table'[Rank] = 1 ) ,
    "2nd quickest average start location", CALCULATE ( FIRSTNONBLANK('New Table'[Start Location],1), 'New Table'[Rank] = 2 ),
    "3rd quickest average start location", CALCULATE ( FIRSTNONBLANK('New Table'[Start Location],1), 'New Table'[Rank] = 3 )
)

 

4. When you show the table on the report, you can apply a visual level filter(2nd quickest average start location is not blank, 3rd quickest average start location is not blank) to exclude the quickest, 2nd quickest and 3rd quickest if they only had 2 entries or less as outliers. Smiley Happy

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @sclennell,

 

If I understand you correctly, you should be able to follow steps below to get your expected result.

 

I assume your called is "Table1".

 

1. Use the formula below to create a new table with each End Location and distinct Time values.

 

New Table = 
SUMMARIZE (
    Table1,
    Table1[Start Location],
    Table1[End Location],
    "Averate Time", AVERAGE ( Table1[Time] )
)

 

2. Use the formula below to add a calculate column to the new created table to Rank Time values for each End Location.

 

Rank = 
VAR t = 'New Table'[Averate Time]
VAR endL = 'New Table'[End Location]
RETURN
    CALCULATE (
        RANK.EQ ( t, 'New Table'[Averate Time], ASC ),
        FILTER ( ALL ( 'New Table' ), 'New Table'[End Location] = endL )
    )

 

3. Then should be able to use the formula below to create a new table with End Location (unique list), Quickest average start location  (Time), 2nd quickest average start location  (Time), 3rd...

 

Final Table = 
SUMMARIZE (
    'New Table',
    'New Table'[End Location],
    "Quickest average start location", CALCULATE ( FIRSTNONBLANK('New Table'[Start Location],1), 'New Table'[Rank] = 1 ) ,
    "2nd quickest average start location", CALCULATE ( FIRSTNONBLANK('New Table'[Start Location],1), 'New Table'[Rank] = 2 ),
    "3rd quickest average start location", CALCULATE ( FIRSTNONBLANK('New Table'[Start Location],1), 'New Table'[Rank] = 3 )
)

 

4. When you show the table on the report, you can apply a visual level filter(2nd quickest average start location is not blank, 3rd quickest average start location is not blank) to exclude the quickest, 2nd quickest and 3rd quickest if they only had 2 entries or less as outliers. Smiley Happy

 

Regards

sclennell
New Member

OK, slightly complex query and I'm a complete PowerBI newbie, so not great with this!

 

I have source data as follows:

 

Start Location    End Location    Time

A                        H                      00:01

B                        J                       02:00

C                        I                       03:03

D                        Z                      01:01

B                       I                        02:00

 

 

The start and end locations are specifc unique locations (different lists from each other - we have a scenario where devices travel from a pool of locations to a different pool of locations).

 

I have approx 100,000 rows of this data, all based on captured data.

 

I am trying to get a table that would give me the following:

 

End Location (unique list)                  Quickest average start location                  2nd quickest average start location            3rd...

 

I also need to exclude the quickest, 2nd quickest and 3rd quickest if they only had 2 entries or less as outliers.

 

I cant work out where to start! Any suggestions greatly appreciated.

 

 

 

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.

Top Solution Authors