Forum Discussion
ndeshpande
6 years agoFrequent Visitor
Checking for Partial Row Matches in the Same Table
Hi Folks, I have an table called "Client_Shipments" with the following columns: [Client_name], [Send_location], [Receive_location], [Cost], [Error_rate]. I'm trying to check if for the client_nam...
- 6 years ago
Hi ndeshpande
You could add it as a new column:Match_Found_Col = VAR cl = [Client_name] VAR sl = [Send_location] VAR rl = [Receive_location] VAR c = COUNTROWS ( CALCULATETABLE ( VALUES ( ClientOrders ), FILTER ( ALL ( ClientOrders ), [Send_location] = sl && [Receive_location] = rl && [Client_name] <> cl ) ) ) + 0 RETURN IF ( c > 0, TRUE (), FALSE () )
Or as a measure:Match_Found_Mes = VAR cl = FIRSTNONBLANK ( ClientOrders[Client_name], 1 ) VAR sl = SELECTEDVALUE ( ClientOrders[Send_location], "123" ) VAR rl = SELECTEDVALUE ( ClientOrders[Receive_location], "123" ) VAR c = COUNTROWS ( CALCULATETABLE ( VALUES ( ClientOrders ), FILTER ( ALL ( ClientOrders ), [Send_location] = sl && [Receive_location] = rl && [Client_name] <> cl ) ) ) + 0 RETURN IF ( c > 0, TRUE (), FALSE () )Cheers
Edit: Ah, sorry parry2k , I hadn't seen your answer.
Smauro
Solution Sage
6 years agoHi ndeshpande
You could add it as a new column:
Match_Found_Col =
VAR cl = [Client_name]
VAR sl = [Send_location]
VAR rl = [Receive_location]
VAR c =
COUNTROWS (
CALCULATETABLE (
VALUES ( ClientOrders ),
FILTER (
ALL ( ClientOrders ),
[Send_location] = sl
&& [Receive_location] = rl
&& [Client_name] <> cl
)
)
) + 0
RETURN
IF ( c > 0, TRUE (), FALSE () )
Or as a measure:
Match_Found_Mes =
VAR cl =
FIRSTNONBLANK ( ClientOrders[Client_name], 1 )
VAR sl =
SELECTEDVALUE ( ClientOrders[Send_location], "123" )
VAR rl =
SELECTEDVALUE ( ClientOrders[Receive_location], "123" )
VAR c =
COUNTROWS (
CALCULATETABLE (
VALUES ( ClientOrders ),
FILTER (
ALL ( ClientOrders ),
[Send_location] = sl
&& [Receive_location] = rl
&& [Client_name] <> cl
)
)
) + 0
RETURN
IF ( c > 0, TRUE (), FALSE () )
Cheers
Edit: Ah, sorry parry2k , I hadn't seen your answer.
- ndeshpande6 years agoFrequent Visitor
This is perfect, thank you!