Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
irechevallejo
Contributor
Contributor

Need Help with Calculated Expression Evaluation in Qlik Sense Mashup

Hello,

I'm working on a Qlik Sense mashup application with AngularJS, and I'm facing a challenge related to calculated expression evaluation. I have a scenario where I want to calculate the count of distinct clients based on a certain expression. Before performing an action, I need to evaluate the client count and take different actions based on the result.

Here's a simplified version of what I'm trying to achieve:

I have a button in my mashup application that triggers a filtering action using a calculated expression. Before applying the filter, I want to calculate the count of distinct clients using an expression. If the calculated client count is above a certain threshold (let's say 20,000), I'd like to display a pop-up message to the user indicating that they need to select a smaller number of clients. If the client count is below the threshold, I want to proceed with the filtering action.

I've attempted to use the createGenericObject method to evaluate the expression and retrieve the client count, but I've encountered challenges in getting the actual calculated value from the response.

Here's my current js code:

$scope.customerFilter = function(expression) {
var clientCountExpression = "=count(distinct Clients)";
 
app.obj.app.createGenericObject({
clientCount: {
qValueExpression: clientCountExpression,
}
}, function(reply) {
var clientCount = reply.clientCount.qValue.qNum;
console.log("Client count:"+clientCount);
if (clientCount > 1000) {
// Display a pop-up message indicating that there are too many clients
alert("Please select a smaller number of clients.");
} else {
//Filter clients
app.obj.app.variable.getContent("vNameClient", function(fieldName) {
var field = app.obj.app.field(fieldName.qContent.qString);
field.selectMatch(expression).then(function() {
console.log("Filtering done");
});
});
}
});
};

 

This is not returning the first console.log.

I would greatly appreciate any guidance or suggestions. Thank you in advance for your help and insights.

Best regards,
Irene

Labels (1)
0 Replies