Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hi,
I have created several Power BI Parameters that are set in the Power BI Service. These parameters are fed, via PQ, to the report. These parameters (these values) are used as a target value.
The team slicer visual consists of three teams (LS, PG, and AHSS). Each team has a parameter value.
I would like it so if the user selects all three teams (whether individually all, or through a 'select all') in the slicer then all three team's parameter values are summed.
If only, say, LS and PS teams are select then only the LS and PS parameters values are summed.
If only, say, LS teams is selected then only the LS parameter value is shown.
Below is my attempt at geting this to work.
__Deal target =
VAR _selectedvalues = VALUES( '__dim_Sub-Team'[Sub-Team] )
VAR _result =
IF(
CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000000" && "200000001" && "200000002" ),
VALUES( 'LS Deal target'[LS Deal target] ) + VALUES( 'PS Deal target'[PS Deal target] ) + VALUES( 'AHSS Deal target'[AHSS Deal target] ),
IF(
CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000000" && "200000001" ),
VALUES( 'LS Deal target'[LS Deal target] ) + VALUES( 'PS Deal target'[PS Deal target] ),
IF(
CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000000" && "200000002" ),
VALUES( 'LS Deal target'[LS Deal target] ) + VALUES( 'AHSS Deal target'[AHSS Deal target] ),
IF(
CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000001" && "200000002" ),
VALUES( 'PS Deal target'[PS Deal target] ) + VALUES( 'AHSS Deal target'[AHSS Deal target] ),
IF(
CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000000" ), //"LS"
VALUES( 'LS Deal target'[LS Deal target] ),
IF(
CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000001" ), //"PS"
VALUES( 'PS Deal target'[PS Deal target] ),
IF(
CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000002" ), //"AHSS"
VALUES( 'AHSS Deal target'[AHSS Deal target] ),
100
)
)
)
)
)
)
)
RETURN
_result + 0
What I get returned is the following error:
Please can someone help with this error?
Thanks.
Solved! Go to Solution.
@D_PBI , I think the issue is because of the values , Try like
Deal Target =
VAR _selectedValues = VALUES('__dim_Sub-Team'[Sub-Team])
RETURN
SWITCH(
TRUE(),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUMX(VALUES('LS Deal target'[LS Deal target]), [LS Deal target]) +
SUMX(VALUES('PS Deal target'[PS Deal target]), [PS Deal target]) +
SUMX(VALUES('AHSS Deal target'[AHSS Deal target]), [AHSS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001"),
SUMX(VALUES('LS Deal target'[LS Deal target]), [LS Deal target]) +
SUMX(VALUES('PS Deal target'[PS Deal target]), [PS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUMX(VALUES('LS Deal target'[LS Deal target]), [LS Deal target]) +
SUMX(VALUES('AHSS Deal target'[AHSS Deal target]), [AHSS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUMX(VALUES('PS Deal target'[PS Deal target]), [PS Deal target]) +
SUMX(VALUES('AHSS Deal target'[AHSS Deal target]), [AHSS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000"),
SUM('LS Deal target'[LS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001"),
SUM('PS Deal target'[PS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUM('AHSS Deal target'[AHSS Deal target]),
100 // Default or other cases
)
Hi @D_PBI
According to your error screenshot, the parameter types in your CONTAINS function have text type and true/false type, which cannot be compared, for example, "CONTAINS( _selectedvalues, '__dim_Sub-Team'[Sub-Team], "200000000" && " 200000001" && "200000002" )", where the first two arguments are text types and the latter is a true/false type. My current suggestion is that you need to change one of the parameter types in order for the comparison to work.
If your problem persists, please provide the sample data and the expected results based on the sample data so that I can better help you. How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show it as screenshots. Please remove any sensitive data in advance.
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@D_PBI , I think the issue is because of the values , Try like
Deal Target =
VAR _selectedValues = VALUES('__dim_Sub-Team'[Sub-Team])
RETURN
SWITCH(
TRUE(),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUMX(VALUES('LS Deal target'[LS Deal target]), [LS Deal target]) +
SUMX(VALUES('PS Deal target'[PS Deal target]), [PS Deal target]) +
SUMX(VALUES('AHSS Deal target'[AHSS Deal target]), [AHSS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001"),
SUMX(VALUES('LS Deal target'[LS Deal target]), [LS Deal target]) +
SUMX(VALUES('PS Deal target'[PS Deal target]), [PS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUMX(VALUES('LS Deal target'[LS Deal target]), [LS Deal target]) +
SUMX(VALUES('AHSS Deal target'[AHSS Deal target]), [AHSS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001") && CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUMX(VALUES('PS Deal target'[PS Deal target]), [PS Deal target]) +
SUMX(VALUES('AHSS Deal target'[AHSS Deal target]), [AHSS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000000"),
SUM('LS Deal target'[LS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000001"),
SUM('PS Deal target'[PS Deal target]),
CONTAINS(_selectedValues, '__dim_Sub-Team'[Sub-Team], "200000002"),
SUM('AHSS Deal target'[AHSS Deal target]),
100 // Default or other cases
)
@amitchandak - thank you. That worked as needed.
@v-xuxinyi-msft - thanks for your response. I have followed @amitchandak method to resolve the need.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
102 | |
68 | |
46 | |
37 | |
37 |