Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Matching Values in Common from 2 Tables

Hello,

I have 2 tables, Budget and Actual.

Budget:

     - Period (X)

     - Amount

     - Account (Y)

     - Detail

     - Qty

     - Society (Z)

     - 'Budget' AS Data_Source

Actual:

     - Period (X)

     - Amount

     - Account (Y)

     - Indicator

     - Society (Z)

     - 'Actual' AS Data_Source

What I need is to generate a KEY between Budget and Actual with fields PERIOD (X), ACCOUNT (Y) and SOCIETY (Z).

I'd need to concatenate all this data but having only the values that match in the generated KEY.

Is there any way to do that?

Thank you!!!

1 Solution

Accepted Solutions
sunny_talwar

May be this

FACT:

LOAD AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z)) as Key,

    - Period (X)

    - Amount

    - Account (Y)

    - Detail

    - Qty

    - Society (Z)

    - 'Budget' AS Data_Source

FROM Budget;

Actual:

Inner Keep(FACT)

LOAD AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z)) as Key,

    - Period (X)

    - Amount

    - Account (Y)

    - Indicator

    - Society (Z)

    - 'Actual' AS Data_Source

FROM Actual;

Concatenate(FACT)

LOAD *

Resident Actual;

DROP Table Actual;

View solution in original post

7 Replies
sunny_talwar

Key can be created using AutoNumber or just simply using & between the fields

LOAD AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z)) as Key

and then to bring only the matching stuff you can use Where Exists() or Inner Keep

microwin88x
Creator III
Creator III
Author

Hello Sunny,

Great! And is it OK to use first Concatenate between both tables?

Thanks!

sunny_talwar

First concatenate? What does that mean?

microwin88x
Creator III
Creator III
Author

I mean I do:

FACT:

LOAD AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z)) as Key,

     - Period (X)

     - Amount

     - Account (Y)

     - Detail

     - Qty

     - Society (Z)

     - 'Budget' AS Data_Source

FROM Budget;

CONCATENATE(FACT)

LOAD AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z)) as Key,

     - Period (X)

     - Amount

     - Account (Y)

     - Indicator

     - Society (Z)

     - 'Actual' AS Data_Source

FROM Actual

WHERE Exists(AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z));


Something like that?

sunny_talwar

This can work, but the only issue can be that it will only check the second table for matching values from first table. BUDGET Table won't check if ACTUAL has matching values or not...

microwin88x
Creator III
Creator III
Author

Oh I see... And would you recommend to achieve that? Thanks!

sunny_talwar

May be this

FACT:

LOAD AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z)) as Key,

    - Period (X)

    - Amount

    - Account (Y)

    - Detail

    - Qty

    - Society (Z)

    - 'Budget' AS Data_Source

FROM Budget;

Actual:

Inner Keep(FACT)

LOAD AutoNumber(PERIOD (X)&'|'&ACCOUNT (Y)&'|'&SOCIETY (Z)) as Key,

    - Period (X)

    - Amount

    - Account (Y)

    - Indicator

    - Society (Z)

    - 'Actual' AS Data_Source

FROM Actual;

Concatenate(FACT)

LOAD *

Resident Actual;

DROP Table Actual;