Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Data Validation on Key Fields

<body><p>I have a data table with seven key fields, all of which are different codes.  For each field, I must validate that all values within that field exist within a separate "code validation table."  I was considering using an INNER JOIN between the data table and each of the "validation tables", but I am not sure this is the best way to do this. </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >Below is an example of my script.  </span>I would like to have the &ldquo;SHIP_TO_CODE&rdquo; field in the &ldquo;DataTable&rdquo; compared against the &ldquo;SHIP_TO_CODE&rdquo; field in the &ldquo;DimCust&rdquo; table.  </span>The outcome of the comparison should be that records containing values in the &ldquo;SHIP_TO_CODE&rdquo; field in the &ldquo;DataTable&rdquo; that do not appear in the &ldquo;DimCust&rdquo; table will be removed. </span><b></span></b></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" > </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><i>DimCust:</span></i></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><b>LOAD</span></b></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >SHIP_TO_CODE</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >BUSINESS_SEGMENT_CODE</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >SALES_</span><st1:stockticker>ORG</span></st1:stockticker></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><b>FROM</span></b></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >.. </span>\</span><st1:stockticker>DATA</span></st1:stockticker>\QVD\DimCustomer.QVD</span></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >(</span>qvd</span>) </span><b>WHERE</span></b>( </span>BUSINESS_SEGMENT_CODE</span> =</span><b><i>'$(vCustBusSegment)'</span></i></b> </span><st1:stockticker><b>AND</span></b></st1:stockticker> </span>SALES_</span><st1:stockticker>ORG</span></st1:stockticker> = </span><b><i>'$(vSalesOrg)'</span></i></b>)</span>;</span></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><i> </span></i></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><i>DataTable:</span></i></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><b>LOAD</span></b></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >FINAL_GI_</span><st1:stockticker>ACTL</span></st1:stockticker>_DT_CD</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >FINAL_GI_</span><st1:stockticker>ACTL</span></st1:stockticker>_DT_CD</span> </span><b>AS</span></b> </span><st1:stockticker>DAY</span></st1:stockticker>_CODE</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >SHIP_TO_CD</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >SOH_ORDER_TYPE_CD</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >SOH_SHIP_COND_CD</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >SOH_SHIP_PNT_CD</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >ORDER_MAKEUP_CD</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >INTER_CO_IN</span>,</span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >COUNT_ORDER</span>, </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >SHIP_TO_CODE</span></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><b>FROM</span></b></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >.. </span>\</span><st1:stockticker>DATA</span></st1:stockticker>\QVD\ODSDrvdSAPSalesOrderHdr_ETL.QVD</span></span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >(</span>qvd</span>);</span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" ><b> </span></b></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >Again, my question is whether or not an INNER JOIN is the best way to accomplish this?  </span>I have also considered using a MAPPING LOAD, but I am not sure how to apply that functionality in this case. </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" > </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >Any assistance is much appreciated. </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" > </span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >Thanks,</span></p> <p style="margin: 0in 0in 0pt; mso-layout-grid-align: none;" >Godfrey</span></p></body>

1 Solution

Accepted Solutions
Not applicable
Author

Take a look at the Keep keyword in the QlikView documentation. AKeep or Left Keep as you load the data will have QlikView do what you need.

View solution in original post

5 Replies
Not applicable
Author

Inner Join will compare the two fields and throw out anything that doesn't have a match.

Does your SHIP_TO_CODE field in DataTable contain more than one value? If so, Inner Join will not work, because Inner Join only works on exact matches.

Not applicable
Author

There are many values that exist in the SHIP_TO_CODE field in the DataTable, but each of these values should have a match in the SHIP_TO_CODE field in the DimCust table. When the value for this field exists in DataTable but not in DimCust, I would like the DataTable record to be excluded.

Thanks,

Godfrey

Not applicable
Author

But is there more than one value per field? Like: ShipA, ShipB, ShipC. If so, that doesn't match ShipA.

If there is one value per record in SHIP_TO_CODE in the DataTable, then it seems like Inner Join would work for you.

Not applicable
Author

Take a look at the Keep keyword in the QlikView documentation. AKeep or Left Keep as you load the data will have QlikView do what you need.

Not applicable
Author

Thank you Tim, I had never thought of using an INNER KEEP (because I never knew it existed). I will give that a try.

Thanks,

Godfrey