Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm stuck with the if statements, below is the code which I'm using.
Example Load statement
Dim:
Load ID,
if(Column1='test1','Testing one',
if(Column1='test2' or Column1='test3','Testing two & three')) as Type1
if(Column1='test1' or Column1='test2' or Column1='test3',Column1)) as Type2
Mapping1:
Load ID, Type1 resident Dim;
Mapping2:
Load ID, Type2 resident Dim;
Fact:
Load Sales, ID_FACT
applymap('Mapping1',ID_FACT,null()) as new_type1,
applymap('Mapping2',ID_FACT,null()) as new_type2
Output:
new_type1 | new_type2 | Sales |
Testing one | test1 | 100 |
Testing two & three | test2 | 0 |
Testing two & three | test3 | 0 |
Expected Output:
new_type1 | new_type2 | Sales |
Testing one | test1 | 100 |
Testing two & three | test2 | 0 |
Testing two & three | test3 | 0 |
Testing two & three | - | 200 |
Regards,
Vikas
@vikasshana can you share a sample data ?
Your output doesn't seem to logically match your conditions, I think. In order for the first field to be Testing two & three, you need the dimension to be either test2 or test3. But if it's either of those, then the second mapping field can't be null - it has to be either test2 or test3.
That said, it's hard to get a full grasp on this without the actual data you're inputting into this script (and also without the ID field from the dimension/fact table since you didn't include those in either section of your output tables).