Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Working with the statements QUALIFY and UNQUALIFY

Hello everyone,

I´m trying to connect two tables by the field Month and Year, using the statements QUALIFY and UNQUALIFY.

See below the script:

Table1:

QUALIFY *;

Restaurant:

LOAD Category,

    
Month(Mês) as Month,

    
Year(Ano) as Year,

    
Consume,

    
[Avg/day],

    
[Payed Value]

FROM  abc;

Table2:

LOAD Month(Mês) as Month,

    
Year(Ano) as Year,

    
[Recuperation Grill],

    
[Recuperation paper],

    
[Recuperation coffee],

    
[Total Recuperation]

FROM abc;

UNQUALIFY Month, Year;

The idea is to create only one filter for Month and Year, creating a relationsheep between both tables.

The script is running with no errors, but there are no relationship, Month and Year are not recognized as same fields.

Anyone could help me to solve that?

Regards,

8 Replies
sunny_talwar

Try this:

QUALIFY *;

UNQUALIFY Month, Year;

Table1:

LOAD Category,
    
Month(Mês) as Month,
    
Year(Ano) as Year,
    
Consume,
    
[Avg/day],
    
[Payed Value]
FROM  abc;

Table2:

LOAD Month(Mês) as Month,
    
Year(Ano) as Year,
    
[Recuperation Grill],
    
[Recuperation paper],
    
[Recuperation coffee],
    
[Total Recuperation]
FROM abc;


UNQUALIFY *;


lironbaram
Partner - Master III

Hi

change to this script

Qualify *;

UnQualify Month,Year;

Table1:

LOAD Category,

    
Month(Mês) as Month,

    
Year(Ano) as Year,

    
Consume,

    
[Avg/day],

    
[Payed Value]

FROM  abc;

Table2:

LOAD Month(Mês) as Month,

    
Year(Ano) as Year,

    
[Recuperation Grill],

    
[Recuperation paper],

    
[Recuperation coffee],

    
[Total Recuperation]

FROM abc;

UNQUALIFY *;

Not applicable
Author

Doint this i have a Synthetic Key as a result...

I am trying to do avoiding Synthetic Keys.

Thanks

Not applicable
Author

Doint this i have a Synthetic Key as a result...

I am trying to do avoiding Synthetic Keys.

Thanks

sunny_talwar

Try this in that case:

  1. QUALIFY *; 
  2. UNQUALIFY MonthYear
  3.  
  4. Table1: 
  5. LOAD Category, 
  6.     Month(Mês) as Month
  7.     Year(Ano) as Year,
  8. MonthName(DateField) as MonthYear, 
  9.     Consume, 
  10.     [Avg/day], 
  11.     [Payed Value] 
  12. FROM  abc; 
  13.  
  14. Table2: 
  15. LOAD Month(Mês) as Month
  16.     Year(Ano) as Year,
  17. MonthName(DateField) as MonthYear
  18.     [Recuperation Grill], 
  19.     [Recuperation paper], 
  20.     [Recuperation coffee], 
  21.     [Total Recuperation] 
  22. FROM abc; 
  23. UNQUALIFY *;

swuehl
MVP

Just as a side note, the arguments of functions Year() and Month() should be date values, not year or month numbers.

Not sure how your Mes values look like, but I do assume that year values are like 2016, right?

So I believe you shouldn't apply Year function, but just rename your Ano field to Year:

...

Ano as Year,

...

Besides that, it might be better to create and use a YearMonth field (Maybe using Makedate(Ano, Mes) as YearMonth) in both tables and link to a common master calendar.

Not applicable
Author

This is how my database look like to Month and year:

Capturar.PNG

swuehl
MVP

Does this work with your data?

Makedate( Ano, Month(Date#(Mes, 'MMMM'))) as YearMonth

[your long month names should be set in your script or OS to make it work]