I have a table with the following structure:
The desired loaded table in Qlik Sense
is as following:
BY this structure, I will be able to add a table showing each doctor, and how many medications he prescribed, and even break it down into detailed pivot table to show what are these meds:
I tried to loop over the initial table [Medications]
(which is coming from a REST API, so we cannot change it before loading to desired form):
FOR Each ev in FieldValueList('Event')
[MedAndDoctors]:
LOAD
$(ev) as event_id,
if (Field = 'Medication1' OR Field=Medication2 OR Field = Medication3 OR..., [Field]) AS med_name,
if (Field = 'Doctor', [Field]) AS doctor_name,
if (Field = 'Medication1 Quantity' OR Field = 'Medication2 Quantity' OR ..., [Field]) AS Quantity
RESIDENT ([Medications]);
WHERE event_id = '$(ev)';
Next ev;
Note that Field
column contains lots of more info. Actually, the survey filled, is saved in a vertical structure, instead of the regular horizontal structure where all values of each event are on the same row.
The result was exactly the same of [Medications]
table but with only the specified field values, so I couldn't display the desired output table.