Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jim_chan
Specialist
Specialist

How to count on fields that have changes in value.

Hi guys,

I have a requirement:

- display total no of records - i assume is count(record_ID) ?

- display records that have made changes of the total of number records?

I have attached a sample qvw with inline data. 

Please help guys.

Rgds,

Jim

1 Solution

Accepted Solutions
robert_mika
Master III
Master III

Missed the concatenate

Record_2015:

LOAD * INLINE [

    Year, Record_ID, Rating

    2015, 001, 10

    2015, 002, 20

    2015, 003, 30

];

Changes:

Mapping Load

Record_ID&Rating as Rating2015,

Rating

resident Record_2015;

 

  Concatenate

Record_2016:

load *,

if(Record_ID&Rating<>Record_ID&ApplyMap('Changes', Record_ID&Rating,0),1) as ChangesFlag;

LOAD * INLINE [

    Year, Record_ID, Rating

    2016, 001, 10

    2016, 002, 10

    2016, 003, 30

];

View solution in original post

24 Replies
jim_chan
Specialist
Specialist
Author

Can I used before() or after() ?

robert_mika
Master III
Master III

Like this:

Record_2015:

LOAD * INLINE [

    Year, Record_ID, Rating

    2015, 001, 10

    2015, 002, 20

    2015, 003, 30

];

Changes:

Mapping Load

 

Record_ID&Rating as Rating2015,

Rating

resident Record_2015;

 

Record_2016:

load *,

if(Record_ID&Rating<>Record_ID&ApplyMap('Changes', Record_ID&Rating,0),1) as ChangesFlag;

LOAD * INLINE [

    Year, Record_ID, Rating

    2016, 001, 10

    2016, 002, 10

    2016, 003, 30

];

Capture.PNG

antoniotiman
Master III
Master III

Hi Jim

may be

Count(DISTINCT {<Record_ID={'=Count(DISTINCT Rating) > 1'}>} Record_ID)

Regards,

Antonio

jim_chan
Specialist
Specialist
Author

woww........ let me test it, let you know in a short while, Mika.

Rgds,

Jim

jim_chan
Specialist
Specialist
Author

Mika,

I got synthetic key after loaded the script as below:

Record_2015:

LOAD * INLINE [

    Year, Record_ID, Rating

    2015, 001, 10

    2015, 002, 20

    2015, 003, 30

];

Changes:

Mapping Load

Record_ID&Rating as Rating2015,

Rating

resident Record_2015;

Record_2016:

load *,

if(Record_ID&Rating<>Record_ID&ApplyMap('Changes', Record_ID&Rating,0),1) as ChangesFlag;

LOAD * INLINE [

    Year, Record_ID, Rating

    2016, 001, 10

    2016, 002, 10

    2016, 003, 30

];

jim_chan
Specialist
Specialist
Author

ok.. this works too, it gave me the no. of record changes too.

sunny_talwar

Or may be one of these:

=Count(DISTINCT {<Record_ID = {"=Len(Trim(Only(Rating))) = 0"}>}Record_ID)

or this if you don't want to distinct count Record_ID

=Count({<Record_ID = {"=Len(Trim(Only(Rating))) = 0"}>}Record_ID)

robert_mika
Master III
Master III

Missed the concatenate

Record_2015:

LOAD * INLINE [

    Year, Record_ID, Rating

    2015, 001, 10

    2015, 002, 20

    2015, 003, 30

];

Changes:

Mapping Load

Record_ID&Rating as Rating2015,

Rating

resident Record_2015;

 

  Concatenate

Record_2016:

load *,

if(Record_ID&Rating<>Record_ID&ApplyMap('Changes', Record_ID&Rating,0),1) as ChangesFlag;

LOAD * INLINE [

    Year, Record_ID, Rating

    2016, 001, 10

    2016, 002, 10

    2016, 003, 30

];

jim_chan
Specialist
Specialist
Author

Hi Sunny,

This works =Count(DISTINCT {<Record_ID = {"=Len(Trim(Only(Rating))) = 0"}>}Record_ID)

But how can i display the Record ID(that have changes) ? in the table box or text object

rgds,

Jim