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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
PrasannaJ
Frequent Visitor

Assign value from one Column in a row to another column in other rows based on a condition

Hi,

I need help in the following:

I have a table like below

SiteURLTraffic
Aurl17
Aurl23
Burl39
Aurl46
Burl50

 

I want to add a 'Preferred URL' column, that provides a possible better URL based on `Traffic` within the `Site`, like below:

 

SiteURLTrafficPreferred URL
Aurl17url1
Aurl23url1
Burl39url3
Aurl46url1
Burl52url3

 

The logic is, within the site, the URL that gets max traffic is treated as the preferred URL for other URLs within the site.

For example, Site 'A' url1 has max traffic = 7, hence it becomes prefer url for Site A url2 & Site A url4. Similarly, Site B url3 becomes the preferred URL for Site B url 5.

Thanks.

1 ACCEPTED SOLUTION
kegoosse
Helper I
Helper I

@PrasannaJ 

This DAX might work if the Traffic values per site are unique

 

Highest traffic per site =
VAR MaxTraffic = CALCULATE(
    MAX(Table[Traffic]),
    FILTER(
        Table,
        Table[Site] = EARLIER(Table[Site])
    )
)
RETURN
CALCULATE(
    FIRSTNONBLANK(Table[URL],TRUE()),
    FILTER(
        Table,
        Table[Site] = EARLIER(Table[Site])
        &&
        Table[Traffic] = MaxTraffic
    )
)

 

 

If Traffic values per site can be repeated, you'll have to add a helper column which converts the traffic values to unique values (for example by adding and index multiplied by 0,000001). Then replace Table[Traffic] with Table[Helper column].

View solution in original post

2 REPLIES 2
PrasannaJ
Frequent Visitor

Awesome. Thanks @kegoosse . I made a small change based on your input as follows:

Highest traffic per site =
VAR MaxTraffic =
    CALCULATE(
        MAX('Table'[Traffic]),
        ALLEXCEPT('Table','Table'[Site])
        )
RETURN
    CALCULATE(
        FIRSTNONBLANK('Table'[Traffic],TRUE()),
        FILTER('Table','Table'[Site]=EARLIER('Table'[Site]) && 'Table'[Traffic]=MaxTraffic )
        )
kegoosse
Helper I
Helper I

@PrasannaJ 

This DAX might work if the Traffic values per site are unique

 

Highest traffic per site =
VAR MaxTraffic = CALCULATE(
    MAX(Table[Traffic]),
    FILTER(
        Table,
        Table[Site] = EARLIER(Table[Site])
    )
)
RETURN
CALCULATE(
    FIRSTNONBLANK(Table[URL],TRUE()),
    FILTER(
        Table,
        Table[Site] = EARLIER(Table[Site])
        &&
        Table[Traffic] = MaxTraffic
    )
)

 

 

If Traffic values per site can be repeated, you'll have to add a helper column which converts the traffic values to unique values (for example by adding and index multiplied by 0,000001). Then replace Table[Traffic] with Table[Helper column].

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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