Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to select data from two separate table

Hi Friends,

It's been a long time.

I recently came up with one situation, that I had to use two different table to bring data into one chart and

those tables are not connected.

In table A I have a field called FACT_TYPE(renamed as FACT_TYPE_A) and in table B I have a FACT_TYPE(renamed as FACT_TYPE_B).

I have attached a sample application, could you please refer to that.

What I need is a macro code that will select FACT_TYPE value from both table. Otherwise I had to select manually from both tables.

Many a thanks beforehand,

Regards,

Bikash Debnath

3 Replies
Not applicable
Author

Hi Everyone,

I tried to solve it this way. I have attached the solution with a sample qvw application.

But I still have another problem, when I do a selection, I am not able to get the Total Sum bar.

Can anyone please help me.

Thanks,

Bikash

johnw
Champion III
Champion III

Quick and dirty answer:

sum(aggr(
if(B_FACT_TYPE='$(vCurrValue)', sum(B_PRICE), if(len(GetCurrentSelections(B_FACT_TYPE))=0, sum(B_PRICE)))
,B_PART_NO))

Now, why DID you rename your FACT_TYPE field in your two tables?  Why don't you want to connect them?

Also note that your approach only gives answers when no or a single A_FACT_TYPE are selected.  If you select more than one, it fails.

Not applicable
Author

Hi John,

Thanks for your prompt response.

The reason why I didn't join FACT_TYPE is because the other details(dimensions) doesn't contain related data.

Only the FACT_TYPE field values are same in both cases. Hence I need both FACT_TYPE only for selection purpose.

thanks,

Bikash Debnath