Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mithunr40
Contributor III
Contributor III

MOD()

Hi Everyone,

I want to know the solution for the below requirement.

Calculate the number of employees whose SALARY is a multiple of 1000. Please use the following fields and functions in set analysis: EMPLOYEE_ID,SALARY,mod()

 

Thank you.

Labels (1)
1 Solution

Accepted Solutions
Gabbar
Specialist
Specialist

as read in @rwunderlich Comments this might be interview question and I hope you would have solved that,
For rest of the people:- 

There Are Two ways to do that:-
1. with help of script:-
TableA:
load Employee_Id,Salary From Source;

noconcatenate
TableB:
Load Employeed_Id,Salary,Mod(Salary,'1000') as Mod;

Drop Table A;
After Doing this in script
in set analysis:- Count({<Mod={'1'}>} distinct Employee_Id)

2. You have loaded only TableA in load Editor and after that there is nothing.
In set analysis :- Count({<Employee_Id={"=(Mod(Salary,'1000')=0)"}>}Distinct Employee_Id)

View solution in original post

3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

This sounds like an exam or interview question. Rather than just type the answer, I'll offer you some hints and challenge you to do your own research. 

You want the number of employees, that would be Count(Distinct EMPLOYEE_ID).
https://help.qlik.com/en-US/sense/May2023/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/CounterAgg...

Mod() returns the remainder of division, so "Mod(SALARY,1000) = 0" would be a SALARY that is a multiple of 1000. 
https://help.qlik.com/en-US/sense/May2023/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/GeneralNum...

You need to add the set analysis in {} to select only EMPLOYEE_ID where Mod(SALARY,1000) = 0.

Count({} Distinct EMPLOYEE_ID)

Reference for Set Analysis: https://help.qlik.com/en-US/sense/May2023/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/SetAnalysi...

-Rob

 

sidhiq91
Specialist II
Specialist II

@mithunr40  You can just create a flag for all the employees whose salary is less than 1000, something like below:

NoConcatenate
Temp:
Load EmpID,Salary,
if(Salary<1000,1,0) as flag
Inline [
EmpID, Salary
1,2000
2,900
3,4000

];

Exit Script;

Then in the front end you can use the below set expression.

Count(distinct {<flag={1}>}EmpID)

Gabbar
Specialist
Specialist

as read in @rwunderlich Comments this might be interview question and I hope you would have solved that,
For rest of the people:- 

There Are Two ways to do that:-
1. with help of script:-
TableA:
load Employee_Id,Salary From Source;

noconcatenate
TableB:
Load Employeed_Id,Salary,Mod(Salary,'1000') as Mod;

Drop Table A;
After Doing this in script
in set analysis:- Count({<Mod={'1'}>} distinct Employee_Id)

2. You have loaded only TableA in load Editor and after that there is nothing.
In set analysis :- Count({<Employee_Id={"=(Mod(Salary,'1000')=0)"}>}Distinct Employee_Id)