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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
lightsection
Contributor III
Contributor III

How to count no. of instance of travel between same countries

Below table shows the source and destination information. I would want to count the no. of instances of travel between 2 cities.

Table.jpg

The desired answer is:

US - Canada = 3

US - Denmark = 2

US - UK = 1

US - Brazil = 1

4 Replies
Clever_Anjos
Employee
Employee

Put

Source and Destination as Dimension

Count(distinct Destination) as Expression

swuehl
MVP
MVP

Maybe like this

LOAD

     Source,

     Destination,

     If(Source precedes Destination, Source & '-' & Destination,Destination &'-'&Source) as Travel

FROM ...

Then create a chart with dimension  Travel and expression

=Count(Travel)

sunny_talwar

This is amazing

sunny_talwar

I guess the MaxString() or MinString() can also work here, right?

UPDATE: RangeMaxString() or RangeMinString()

UPDATE2: Something like this:

Table:

LOAD *,

  RangeMaxString(Source, Destination) & '-' & RangeMinString(Destination, Source) as Travel;

LOAD * Inline [

Source, Destination

US, Canada

US, Denmark

Canada, US

Denmark, US

UK, US

US, Canada

US, Brazil

];

UPDATE3:

Capture.PNG