Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
americanetsMD
Contributor III
Contributor III

Field matching

Hello everyone,

I have a little problem in getting two fields matched... in order to explain my issue better, consider the following situation:

I have a fact table, where i have the following fields:

FactTab:

KreditorNr | DebitorNr | KreditorGroup | DebitorGroup | KreditorDebitorFlag | sales

1                     |    -                  |  a                           |   -                           |Kredior                           | 200

2                     |    -                  |  b                           |   -                           |Kredior                           | 100

3                     |    -                  |  c                           |   -                           |Kredior                           | 200

-                      |22                  |  -                            |   e                          |Debitor                            | 50

-                      |23                  |  -                            |   b                          |Debitor                            | 50

-                      |24                  |  -                            |   b                          |Debitor                            | 60

My task is to show the kreditorNr and DebitorNr that are having the same group assigned. Besides, based on the KreditorDebitorFlag  , the sales have to be calculated. As result i should get something like:

KreditorNr | DebitorNr | KreditorGroup | DebitorGroup | KreditorDebitorFlag | sales | GroupMatch

1                     |    -                  |  a                           |   -                           |Kredior                           | 200   | No Match

2                     |    -                  |  b                           |   -                           |Kredior                           | 100   | Match

3                     |    -                  |  c                           |   -                           |Kredior                           | 200   | No Match

-                      |22                  |  -                            |   e                          |Debitor                            | 50    | No Match

-                      |23                  |  -                            |   b                          |Debitor                            | 50    | Match

-                      |24                  |  -                            |   b                          |Debitor                            | 60    | Match

 

Or maybe is there any other way, possibility to get a desired Pivot Table that would look like:

·CommonGroup                           

        °KreditorNr                   

         °DebitorNr          |           Kreditorsales    | Debitorsales

______________________100___________110___________

 ·b                                    |                                          |

       °2                              |             100                     |     - 

       °23                            |             -                          |     50

       °24                            |             -                          |     60

 

I will be really thankful if anyone could help me sort this out.

Many Thanks

 

Labels (1)
1 Solution

Accepted Solutions
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can change the mapping load:

 

_map_kred:

Mapping Load

KreditorGroup

'Match' as Flag

resident data

where KreditorGroup  <> '-'

;

 

_map_deb:

Mapping Load

DebitorGroup,

'Match' as Flag

resident data

where DebitorGroup <> '-'

;

Help users find answers! Don't forget to mark a solution that worked for you!

View solution in original post

5 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can use mapping load and applymap:

_map_kred:

Mapping Load

  KreditorGroup

  'Match' as Flag

resident data

;

 

_map_deb:

Mapping Load

  DebitorGroup,

  'Match' as Flag

resident data

;

 

data2:

Load

  *,

  ApplyMap('_map_kred', DebitorGroup, ApplyMap('_map_deb', KreditorGroup, 'No Match')) as GroupMatch

Resident data

;

 

Drop Table data;

  

Help users find answers! Don't forget to mark a solution that worked for you!
americanetsMD
Contributor III
Contributor III
Author

Hi Aurelien, your theory has unfortunately not worked. I get "Match" by every DebitorGroup and KreditorGroup, as if the ApplyMap would not work...

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can change the mapping load:

 

_map_kred:

Mapping Load

KreditorGroup

'Match' as Flag

resident data

where KreditorGroup  <> '-'

;

 

_map_deb:

Mapping Load

DebitorGroup,

'Match' as Flag

resident data

where DebitorGroup <> '-'

;

Help users find answers! Don't forget to mark a solution that worked for you!
americanetsMD
Contributor III
Contributor III
Author

Hi Aurelien, the where condition will not work because every group is assigned to a number. This means, every KreditorNr has a KreditorGroup assigned. But KreditorNr cannot be equal to DebitorNr.

PrashantSangle

try below

 

Fact:
Load * inline [
KreditorNr | DebitorNr | KreditorGroup | DebitorGroup | KreditorDebitorFlag | sales
 
1                     |    -                  |  a                           |   -                           |Kredior                           | 200
 
2                     |    -                  |  b                           |   -                           |Kredior                           | 100
 
3                     |    -                  |  c                           |   -                           |Kredior                           | 200
 
-                      |22                  |  -                            |   e                          |Debitor                            | 50
 
-                      |23                  |  -                            |   b                          |Debitor                            | 50
 
-                      |24                  |  -                            |   b                          |Debitor                            | 60
](delimiter is '|');
 
 
 
Test:
Load Distinct KreditorGroup as matchKreditorGroup Resident Fact
where KreditorGroup <>'-'
;
 
matchgroup:
Load Distinct DebitorGroup,
'match' as flag Resident Fact
where Exists(matchKreditorGroup,DebitorGroup)
and DebitorGroup <>'-'
;
 
Left Join (Fact)
Load DebitorGroup, flag Resident matchgroup;
 
Left Join
Load DebitorGroup as KreditorGroup , flag as newflag Resident matchgroup;
 
Final:
Load KreditorNr, 
DebitorNr,
    KreditorGroup,
    DebitorGroup,
    KreditorDebitorFlag,
    sales,
    flag as dbflag,
    newflag as krflag,
    if(flag='-' or IsNull(flag),newflag,flag) as flag
Resident Fact;
 
Drop table Test, matchgroup,Fact;
 
Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂