Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
ioannaiogr
Creator II
Creator II

kpi goes '-' when no year is selected

Hi experts.

In a kpi I have tried to calculate the count of all ids that by each of types their last result is negative simultaneously.

So it looks like 

Count(DISTINCT {<[ID] ={"=RangeMaxString([Last result  of type1],[last result of type2], [last result of type3] = 'neg'"}>} [ID])

2 Q's

1) Is it a good way to calculate this?

2) Why does it go "-" if no year is selected? When I pick a year it gives back a number.

 

Many thanks in advance

8 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Do ID values repeat across years?

-Rob

ioannaiogr
Creator II
Creator II
Author

Hi @rwunderlich, no. 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Can you post a screenshot of your data model?

-Rob

ioannaiogr
Creator II
Creator II
Author

Hi @rwunderlich  this is my model

The checkings table can be broken down to three groups of check IDs. Here I will only show for group1, table checkings1. This checkings1 table involves different types of checkings for this group of checks (field “type” of table checkings1).

checkings:

LOAD

    "ID",

     date(floor("checkdate"),'DD/MM/YYYY') as checkdate,

     date("checkdate",'DD/MM/YYYY hh:mm:ss.ffffff') as “checkdate timestamp”,

    "check ID"

FROM [$(vPathQVD)/checking.qvd]

(qvd);

LEFT JOIN(checkings)

LOAD

    "Result ",

"Type",

     "check ID1" as "check ID ",

    “check ID1”

FROM [$(vPathQVD)/checkings1.qvd]

(qvd);

 

LEFT JOIN (checkings)

 

LOAD

   "ID ",

    “Type",

    Date(Max( "checkdate")) AS [last checkdate of checkings1]

    , max("check ID") as maxcheck1_id

RESIDENT

               checkings

GROUP BY

    "ID",

    "Type"             

;

For Each vType In FieldValueList('Type')

 

               [$(vType) Checking1 Details]:

               LOAD

                              "ID”,

        maxckeck1_id as [ID of last checking1 type $(vType)],

       [result] as [last result of checking1 type $(vType)]

    RESIDENT

                              checkings

               WHERE

                "Type" = '$(vType)'

       AND [check ID] = maxcheck1_id

               ;

   

Next vType

 

DROP FIELD [last checkdate of checkings1] FROM checkings;

 

And then I have a master calendar on field “checkdate”

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

What I want to see is the graph of the data model, available from the menu "Data Model Viewer".

ioannaiogr
Creator II
Creator II
Author

Hi @rwunderlich , i am sorry for the delay, here is the data model

 

ioannaiogr
Creator II
Creator II
Author

@rwunderlich , just  noticed that yes, IDs repeat through years!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think the best solution would be to assign a unique key for each row. You can do this in the script with

RecNo() as Key

and then use "Key" as your selector. 

Count(DISTINCT {<[Key] ={"=RangeMaxString([Last result  of type1],[last result of type2], [last result of type3] = 'neg'"}>} [ID])

-Rob