I have a scenario where I need to connect 2 things, what it exactly means is :
1. I have table (Excel) where I have Data like frequencies.
2. I have a SQL query.
Inside the query there are frequencies data which are out dated, and the excel contains the latest frequencies data. So All I need to do is,
Take the frequency data and replace it with the SQL query (But I need to replace only the frequency part, not the whole query.)
Below is the data for your reference,
Can Alteryx do this?? I need a solution for this scenario.
Table :
NAMES | FREQUENCY |
ABC-123 | FRI,TUE |
ABC-110 | MON,THU |
ABC-111 | FRI,SAT,SUN,THU,TUE,WED |
ABC-112 | FRI,TUE |
ABC-113 | FRI,TUE |
ABC-114 | FRI,SAT,SUN,THU,TUE,WED |
ABC-115 | MON,SAT,SUN |
ABC-116 | SAT,TUE |
ABC-117 | FRI,MON,SAT,SUN,THU,TUE,WED |
SQL Query :
-- Dummy Feed Missing Data Checker with Custom Feeds
WITH feed_schedule (NAMES, FREQUENCY) AS (
SELECT 'ABC-123', 'FRI,TUE' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-110', 'MON,THU' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-111', 'FRI,SAT,SUN,THU,TUE,WED' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-112', 'FRI,TUE' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-113', 'FRI,TUE' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-114', 'FRI,SAT,SUN,THU,TUE,WED' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-115', 'MON,SAT,SUN' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-116', 'SAT,TUE' FROM DUMMY_TABLE UNION ALL
SELECT 'ABC-117', 'FRI,MON,SAT,SUN,THU,TUE,WED' FROM DUMMY_TABLE
),
calendar_dates (EFFDATE) AS (
SELECT DATE('2025-08-18') FROM DUMMY_TABLE
UNION ALL
SELECT EFFDATE + 1 DAY FROM calendar_dates WHERE EFFDATE + 1 DAY <= DATE('2025-08-22')
),
expected_feeds (NAMES, EFFDATE) AS (
SELECT fs.NAMES, cd.EFFDATE
FROM feed_schedule fs
JOIN calendar_dates cd ON 1=1
WHERE DAYNAME(cd.EFFDATE) IN (
SELECT TRIM(VALUE) FROM TABLE(SYSPROC.STRING_TO_TABLE(fs.FREQUENCY, ','))
)
),
actual_feeds AS (
SELECT NAMES, EFFDATE, RECSTATUS1
FROM DUMMY_FEED_DATA
WHERE EFFDATE BETWEEN DATE('2025-08-18') AND DATE('2025-08-22')
),
feed_check AS (
SELECT ef.NAMES, ef.EFFDATE,
af.RECSTATUS1
FROM expected_feeds ef
LEFT JOIN actual_feeds af
ON ef.NAMES = af.NAMES AND ef.EFFDATE = af.EFFDATE
)
SELECT *
FROM feed_check
ORDER BY NAMES, EFFDATE
WITH UR;
When I have these type of cases that the text structure matters, such is xml or in this the query, I add RecordID so I can put the data back in the correct order.
I will add filter to get the needed data, let say in your case lines that contains [NAMES] from the excel. Then with RegEx or other method replace the needed text and union the data back, add Sort tool to get the structure of the text and remove the RecordID, now you have the SQL query with the new data.
Hey @OTrieger ,
Thank you for your reply.
If possible can you make a workflow with the data I have provided (Excel and Query). That would be very helpful for me.
I do not share workflow. I can assist and give suggestions on how I would do things. The only way out is to go through it, that is how the person learns to apply the knowledge that he or she learned.
Adding a RecordID and match the data based on NAMES is not a too hard task to do, just work it out, that is how you will learn how to do it.
Okay, Can you please guide me in detailed, Because what you are trying to say, I am not able to understand.
Connect the input that comes from SQL to RecordID, so you will have the correct order of the query.
Then with RegEx Tokenize \U\U\U-\d\d\d, now you will have a new row with the NAMES
Join using NAMES, now you will have all the lines that will need to be updates.
Now you can empty the 'FRI' so you will end only with '' and then replace the '' with the new frequency.
You can use IF statement so only the ' ' that do not contain - will be replaced.
with Select tool remove all the unneeded fields and union it with the rest of the data. Add Sort Tool and then sort it by record ID. Remove RecordID field.
User | Count |
---|---|
60 | |
24 | |
24 | |
21 | |
21 |