Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Tags (3)
3 Replies
Not applicable

Re: Macro to select data from two separate table

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

MVP
MVP

Re: Macro to select data from two separate table

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

Re: Macro to select data from two separate table

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

Community Browser