When you are using this expression
"myfeature" IN (1072566, 1072375, 9400438, 1072569, 3241157, 1072376)
you are comparing an integer to an array of integer that's why it works. When you are using this expression
"myfeature" IN ("variablename")
you are comparing an integer to a string, so it wont work. You need to create an array of string and convert your integer as a string.
You should create your string without parenthesis like this
'1072566, 1072375, 9400438, 1072569, 3241157, 1072376'
.
And then create an array based on this string in the query builder with the function string_to_array, string_to_array("variablename", ', ')
. Your array will look like this ['1072566', '1072375', '9400438', '1072569', '3241157', '1072376']
, it's an array of string.
"myfeature"
needs to be a string aswell, you can use the function to_string, to_string("myfeature")
Finally, to compare an array and a value you can use the function array_contains,array_contains(string_to_array("variablename", ', '),to_string("myfeature"))
Best Answer
Under the "Filter" for rule based labeling write
"Priority" = 'P1'
(note the double brackets around the column, and the single brackets around the expected result). Single brackets are needed as the expression is searching for a string. The only time you don't need to use single brackets would be when searching for integers.