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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jacob_Weig
Contributor III
Contributor III

Creating a flag dimension based on a nested query

Hi, 

Not sure what solution is best whether directly in the load editor or in the front end but basically I want to create a flag for when the sum by id is equal to 0.

This is what I would do in sql:

/*first filter id where sum per id is 0*/

with cte as
(select id
from my_table
group by 1
having sum(paid_amount)=0
)

select * , case when b.id is null the 1 else 0 end as cero_flag
from my_table a
left join cte b on a.id=b.id

2 Replies
tensini
Contributor II
Contributor II

Table:
LOAD
id,
paid_amount,
fields...
FROM source;


Left Join (Table)
LOAD
id,
If( sum(paid_amount)=0, 1, 0) as zero_flag
RESIDENT Table
Group By id;

Jacob_Weig
Contributor III
Contributor III
Author

It worked perfectly, thank you!!