QuickSight Dataset filter with Multiple values using SDK not working

Hi Team,

I want to apply filter at dataset level having multiple values for ex., Currency - USD, EUR, when I am trying to apply it using Quicksight UI it is working as expected. Refer SS below.

My case is to achieve the same using QuickSight SDK but when I am trying to push the json it is not working as expected.

Json -
{
“projectOperation” : null,
“filterOperation” : {
“conditionExpression” : “({Type}="Accessories") OR (({Type}="Audio") OR ({Type}="Camera"))”
},
“createColumnsOperation” : null,
“renameColumnOperation” : null,
“castColumnTypeOperation” : null,
“tagColumnOperation” : null,
“untagColumnOperation” : null,
“overrideDatasetParameterOperation” : null
}

When applied through SDK, it show the condition expression value as string & also I am not able to modify it on UI. Please note, I tried to extract the JSON for the dataset that I have created manually and publish the same thorugh API but it didn’t work. Kindly suggest if I am missing something.

SDK Version - 1.12.665

Thanks

Hello @anshul1243

To achieve your goal of applying a filter at the dataset level using the Amazon QuickSight SDK, you’ll need to ensure that the JSON structure and syntax are correct and compatible with the SDK’s requirements. From your description, it seems like the JSON is not being interpreted correctly when passed through the SDK.

Here are a few steps and considerations to help troubleshoot and resolve this issue:

  1. Verify JSON Structure: Ensure that your JSON structure aligns with what the SDK expects. The filter condition should be properly defined within the FilterOperation object.
  2. Proper Escaping and Formatting: Make sure that the JSON string is correctly formatted and escaped. For instance, the double quotes around the keys and values should be properly handled.
  3. API Documentation: Refer to the Amazon QuickSight SDK documentation to ensure you’re using the correct fields and syntax.

Here’s an example of how the JSON should be structured for the FilterOperation:

{
    "projectOperation": null,
    "filterOperation": {
        "conditionExpression": "({Type} = 'Accessories') OR ({Type} = 'Audio') OR ({Type} = 'Camera')"
    },
    "createColumnsOperation": null,
    "renameColumnOperation": null,
    "castColumnTypeOperation": null,
    "tagColumnOperation": null,
    "untagColumnOperation": null,
    "overrideDatasetParameterOperation": null
}

Example Using QuickSight SDK

Here is an example of how you might use the SDK to update the dataset with the filter condition:

import boto3

client = boto3.client('quicksight', region_name='us-east-1')

response = client.update_data_set(
    AwsAccountId='YOUR_AWS_ACCOUNT_ID',
    DataSetId='YOUR_DATASET_ID',
    ImportMode='SPICE',
    LogicalTableMap={
        'LogicalTableId': {
            'Alias': 'YourTableAlias',
            'DataTransforms': [
                {
                    'ProjectOperation': None,
                    'FilterOperation': {
                        'ConditionExpression': "({Type} = 'Accessories') OR ({Type} = 'Audio') OR ({Type} = 'Camera')"
                    },
                    'CreateColumnsOperation': None,
                    'RenameColumnOperation': None,
                    'CastColumnTypeOperation': None,
                    'TagColumnOperation': None,
                    'UntagColumnOperation': None,
                    'OverrideDatasetParameterOperation': None
                }
            ]
        }
    }
)

print(response)

Debugging Steps

  1. Log and Inspect Response: Check the response from the update_data_set API call to see if there are any error messages or indicators of what might be wrong.
  2. Simplify Condition Expression: Start with a simpler condition to see if it works and then build up to the more complex condition.

If you still encounter issues, providing more details on the error messages or behavior can help further diagnose the problem.

Hi @Xclipse ,

Thanks for your response, i tried to follow solution you have provided but it didn’t work. Dataset is getting created but the filter is disabled on QS. Please refer ss below. If I tried to use single value in filter then it is working fine, when Brand = FunProd


Let me know if you need any additional information from my end.

Thanks,

Json -
“747c5fdc-ede0-4aaf-bdfb-b1110a84023e” : {
“alias” : “Intermediate_4”,
“dataTransforms” : [ {
“projectOperation” : null,
“filterOperation” : {
“conditionExpression” : “{Brand}="FunPod"”
},
“createColumnsOperation” : null,
“renameColumnOperation” : null,
“castColumnTypeOperation” : null,
“tagColumnOperation” : null,
“untagColumnOperation” : null,
“overrideDatasetParameterOperation” : null
}, {
“projectOperation” : null,
“filterOperation” : {
“conditionExpression” : “{Name}="Abhishek Arya|LLA|Abigail Hardy|LLA|Abner Abrams|LLA|Adah Bacon"”
},
“createColumnsOperation” : null,
“renameColumnOperation” : null,
“castColumnTypeOperation” : null,
“tagColumnOperation” : null,
“untagColumnOperation” : null,
“overrideDatasetParameterOperation” : null
}, {
“projectOperation” : null,
“filterOperation” : {
“conditionExpression” : “({Type} = ‘Accessories’) OR ({Type} = ‘Audio’)”
},
“createColumnsOperation” : null,
“renameColumnOperation” : null,
“castColumnTypeOperation” : null,
“tagColumnOperation” : null,
“untagColumnOperation” : null,
“overrideDatasetParameterOperation” : null
} ],
“source” : {
“joinInstruction” : {
“leftOperand” : “98fda503-ade8-46ab-a351-89208f4aa3da”,
“rightOperand” : “samp-empl-parent-child-map”,
“leftJoinKeyProperties” : null,
“rightJoinKeyProperties” : null,
“type” : “INNER”,
“onClause” : “{Empl Key} = {Member Key}”
},
“physicalTableId” : null,
“dataSetArn” : null
}
},

Hi @Xclipse , Team,

Can you please help on above question.

Thanks in advance.

Hi @anshul1243, I’m out of ideas. Sorry, currently this is not possible but I’m marking this for feature request. At AWS, their roadmap is primarily driven by customers. Your feedback helps them build a better service. I have tagged this as a feature request. More features are being added on a regular basis, so please keep an eye on the What’s New / Blog . You can set up a Watching Alert by clicking on the bell icon.

You could look to opening up a case with AWS and see if they can provide a solution.

Here are the steps to open a support case . If your company has someone who manages your AWS account, you might not have direct access to AWS Support and will need to raise an internal ticket to your IT team or whomever manages your AWS account. They should be able to open an AWS Support case on your behalf. Hope this helps!

2 Likes