Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi,
I need help in the following:
I have a table like below
Site | URL | Traffic |
A | url1 | 7 |
A | url2 | 3 |
B | url3 | 9 |
A | url4 | 6 |
B | url5 | 0 |
I want to add a 'Preferred URL' column, that provides a possible better URL based on `Traffic` within the `Site`, like below:
Site | URL | Traffic | Preferred URL |
A | url1 | 7 | url1 |
A | url2 | 3 | url1 |
B | url3 | 9 | url3 |
A | url4 | 6 | url1 |
B | url5 | 2 | url3 |
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.
Solved! Go to Solution.
@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].
Awesome. Thanks @kegoosse . I made a small change based on your input as follows:
@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].
User | Count |
---|---|
12 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
27 | |
19 | |
13 | |
11 | |
7 |