The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi.
I'm making tracking URLs, so that when clicking url customer is redirected straight to spesific url.
I have the parcels in table "dw parcels" and the conditions in column "r04puins" in table "dw lahetystilasto".
What I have tried so far as column and as measure:
URL for tracking =
IF('dw lahetystilasto'[r04puins] = "Posti",
CONCATENATE("https://www.posti.fi/fi/seuranta#/lahetys/",'dw parcels'[parcelno]),
IF('dw lahetystilasto'[r04puins] = "DB Schenker np",
CONCATENATE("https://ng.myschenker.fi/npseuranta/?id=", 'dw parcels'[parcelno]),
IF('dw lahetystilasto'[r04puins] = "Pakettipiste",
CONCATENATE("https://pakettipisteseuranta.r2web.fi/?tid=", 'dw parcels'[parcelno]),
IF('dw lahetystilasto'[r04puins] = "DHL",
CONCATENATE("https://www.dhl.com/fi-fi/home/tracking/tracking-express.html?submit=1&tracking-id=", 'dw parcels'[parcelno]),
IF('dw lahetystilasto'[r04puins] = "DB Schenker",
CONCATENATE("https://eschenker.dbschenker.com/app/tracking-public/?refNumber=", ''dw parcels'[parcelno])
)))))
Also tried this:
URL for tracking = SWITCH([r04puins],
"Posti", CONCATENATE("https://www.posti.fi/fi/seuranta#/lahetys/",'dw parcels'[parcelno]),
"DB Schenker np", CONCATENATE("https://ng.myschenker.fi/npseuranta/?id=", 'dw parcels'[parcelno]),
"Pakettipiste", CONCATENATE("https://pakettipisteseuranta.r2web.fi/?tid=", 'dw parcels'[parcelno]),
"DHL", CONCATENATE("https://www.dhl.com/fi-fi/home/tracking/tracking-express.html?submit=1&tracking-id=", 'dw parcels'[parcelno]),
"DB Schenker", CONCATENATE("https://eschenker.dbschenker.com/app/tracking-public/?refNumber=", 'dw parcels'[parcelno]),
"Matkahuolto", CONCATENATE("https://www.matkahuolto.fi/seuranta?parcelNumber=", 'dw parcels'[parcelno]),
" " )
Both are giving error that "can't find parcelno" or the syntax is wrong etc.
Any tip how I should proceed with this?
Solved! Go to Solution.
@HeiJoe
Ok. Please try the following code for a calculated table > New Table
Addresses Table =
GENERATE (
'dw parcels',
SELECTCOLUMNS (
RELATEDTABLE ( 'dw lahetystilasto' ),
"URL for tracking",
VAR r04puins = 'dw lahetystilasto'[r04puins]
VAR parcelno = 'dw parcels'[parcelno]
RETURN
SWITCH (
r04puins,
"Posti", "https://www.posti.fi/fi/seuranta#/lahetys/" & parcelno,
"DB Schenker np", "https://ng.myschenker.fi/npseuranta/?id=" & parcelno,
"Pakettipiste", "https://pakettipisteseuranta.r2web.fi/?tid=" & parcelno,
"DHL",
"https://www.dhl.com/fi-fi/home/tracking/tracking-express.html?submit=1&tracking-id=" & parcelno,
"DB Schenker", "https://eschenker.dbschenker.com/app/tracking-public/?refNumber=" & parcelno
)
)
)
@HeiJoe
Ok. Please try the following code for a calculated table > New Table
Addresses Table =
GENERATE (
'dw parcels',
SELECTCOLUMNS (
RELATEDTABLE ( 'dw lahetystilasto' ),
"URL for tracking",
VAR r04puins = 'dw lahetystilasto'[r04puins]
VAR parcelno = 'dw parcels'[parcelno]
RETURN
SWITCH (
r04puins,
"Posti", "https://www.posti.fi/fi/seuranta#/lahetys/" & parcelno,
"DB Schenker np", "https://ng.myschenker.fi/npseuranta/?id=" & parcelno,
"Pakettipiste", "https://pakettipisteseuranta.r2web.fi/?tid=" & parcelno,
"DHL",
"https://www.dhl.com/fi-fi/home/tracking/tracking-express.html?submit=1&tracking-id=" & parcelno,
"DB Schenker", "https://eschenker.dbschenker.com/app/tracking-public/?refNumber=" & parcelno
)
)
)
I was able to create the calculated table, but seems that I can't make relationship from that table to 'dw lahetystilasto'? I got error "Circular depency was detected". Should that even be possible, to make relationships with calculated table?
Then we can add the URL column to the table. Otherwise you need to create this table in power query
If user selects one order, there should be only those parcel URL visible. How should the user know which URL are connected that spesific order?
Hi @HeiJoe
What is the relationship between the two tables? If 'dw parcels' is at the one side of a one to many relationship with 'dw lahetystilasto', the you can use the following. Otherwise please provide your criteria for filtering 'dw parcels'[parcelno]
URL for tracking =
CONCATENATEX (
RELATEDTABLE ( 'dw parcels' ),
VAR r04puins = 'dw lahetystilasto'[r04puins]
VAR parcelno = 'dw parcels'[parcelno]
RETURN
SWITCH (
r04puins,
"Posti", "https://www.posti.fi/fi/seuranta#/lahetys/" & parcelno,
"DB Schenker np", "https://ng.myschenker.fi/npseuranta/?id=" & parcelno,
"Pakettipiste", "https://pakettipisteseuranta.r2web.fi/?tid=" & parcelno,
"DHL", "https://www.dhl.com/fi-fi/home/tracking/tracking-express.html?submit=1&tracking-id=" & parcelno,
"DB Schenker", "https://eschenker.dbschenker.com/app/tracking-public/?refNumber=" & parcelno
),
UNICHAR ( 10 )
)
Here is picture from the relationship.
@HeiJoe
So for each shipmentno you have multiple parcelno. Which one one of them would you like to retrun? The last one i.e. the max one?
All parcelno's from each shipmentno, so I can get URL for all parcel's.
Hi @HeiJoe
Please try this calculated column
URL for tracking =
CONCATENATEX (
RELATEDTABLE ( 'dw parcels' ),
VAR r04puins = 'dw lahetystilasto'[r04puins]
VAR parcelno = 'dw parcels'[parcelno]
RETURN
SWITCH (
r04puins,
"Posti", "https://www.posti.fi/fi/seuranta#/lahetys/" & parcelno,
"DB Schenker np", "https://ng.myschenker.fi/npseuranta/?id=" & parcelno,
"Pakettipiste", "https://pakettipisteseuranta.r2web.fi/?tid=" & parcelno,
"DHL", "https://www.dhl.com/fi-fi/home/tracking/tracking-express.html?submit=1&tracking-id=" & parcelno,
"DB Schenker", "https://eschenker.dbschenker.com/app/tracking-public/?refNumber=" & parcelno
)
)
That almost did it. Just that is should be in own rows, not in one long strin with all URLs. It works when there is only one parcelno in one shipment.
I have edited the code adding UNICHAR (10). If you want completely separate rows then you need to create a new calculated table. Please let me know if this option is acceptable for you?
Yes, I need those completely separate rows. Any tip for that?
@HeiJoe
Sorry I'm a little confused. originally you got an error that says "can't find parcelno" which means that you were trying to create a column in the 'dw lahetystilasto' table. Now the last screenshot shows that you are creating the column in the 'dw parcels' table. Please confirm which columns do you want to see in the new calculated table?
That picture was not from table, it was from visualizations. "Url for Tracking" is in "dw lahetystilasto". I need to see shipmentnumber, parcelno and that "Url for Tracking" in one table.
@HeiJoe
Are you creating a Measure or a Calculated Column?
Ensure you have the column 'dw parcels'[parcelno] in the filter context
You may share a a screenshot
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |