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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Federicofkt
Contributor III
Contributor III

Intersection giving wrong results

I'm trying to perform an intersection in the set analysis using this formula:

 

=count( {
<[Company.id] = P({<Year= {'2024'}, TypeF={'REFAZ'}, [Company.Type]={'A'}>})>
*
<[Company.id] = P({<Year= {'2025'}, TypeF={'REFAZ'}, [Company.Type]={'A'}>})>
}
distinct [Company.id])

 

The formula is returning no errors, hence it is giving me wrong results, since if I use the two measures separated in two columns, I have companies with 1 for both 2024 and 2025 that got 0 in the intersection, and companies with 1 in 2025 and 0 in 2025 that got 1 in the intersection.

 

What am I doing wrong?

 

Labels (1)
4 Replies
agigliotti
Partner - Champion
Partner - Champion

Hi @Federicofkt ,

Could you post a straight table with company id, year, TypeF and company type as dimensions and the two measures?

marcus_sommer

Maybe in this way:

=count({<Year= {'2024'}, TypeF={'REFAZ'}, [Company.Type]={'A'} >
<Year= {'2025'}, TypeF={'REFAZ'}, [Company.Type]={'A'}>distinct [Company.id])

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi everyone,

I tested this, and I believe that the issue here is using the ID field for counting. Examine the following screenshot:

Oleg_Troyansky_0-1746554068915.png

- The first column is a simple distinct count of the field Customer (which is an attribute in the Customers table) - 199 customers in total

- The second column is the intersection of possible values of the same field Customer, where the intersection is defined within a single Set Modifier <...> - 174 customers.

- The third column is the same condition, where the intersection is defined across two different modifiers: <...> * <...>, and the result is the same as in column 2 - 174 customers.

- Then, testing the idea suggested by Marcus, I simplified the condition to the intersection of two sets, with just the Year conditions, skipping the Customer filters and functions P() - same result.

- Finally, I modified the same expression, replacing the Customer field with the key field [%Customer ID], and that's when the expression turned to zero. 

In conclusion - don't use key fields for counting. You may get ambiguous results, and Qlik intentionally prohibits that.

Cheers,

 

agigliotti
Partner - Champion
Partner - Champion

Yes, I remember I faced the same in the past in an intersection scenario.