Forum Discussion

mark_carlisle's avatar
mark_carlisle
Icon for Advocate IV rankAdvocate IV
8 years ago
Solved

Add data to a table from another table as long as it does not exist

I have some data that I am pulling in via a SQL query, I'll call this the PingTable, which is in the format;

 

SerialNumVersionFirstPing
AAA1111001/02/2018
AAA222701/02/2015
AAA333801/02/2016
AAA4441001/02/2018
AAA5551001/02/2018
AAA666901/02/2017
AAA777  
AAA8881001/02/2018
AAA999901/02/2017
BBB111801/02/2016

 

This data is the serial number of the product, the version of said product and the date the product first pinged a server. Due to the way this database is mananged the data is rolled up periodically so the FirstPing date can change, this is where the problem lies. What we like to do is generate a transactional table of when each serial number changes version, so we can track how well the deployment is going and analyse the effectiveness of various communitcation channels.

 

I'm open to suggestions on how to do this but I think the easiest way would be to start with a blank table, I'll call this the VersionTable, and when we refresh the PingTable there is some form of M/DAX expression which looks at the data in the PingTable, checks if the SerialNum from the PingTable exisits in the VersionTable, if it does not exist it adds a row of data like this; 

 

SerialNumVersionFirstPing
AAA1111101/09/2018

 

If it does exist in the VersionTable then it does not add any data. Therefore we will only have one row per SerialNum in the VersionTable along with an uncorruptable date of when it first installed the new version.

 

Thanks in advance.