Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Experts, please help me to fix the DAX code as it's erroring out SUM cannot work with values of type string.
One of the columns that you are using in the SUM function has a String datatype, which can't be used in the SUM function.
You need to go into your Power Query or Source level and make sure that the columns you are using in your SUM Function are of numeric datatype.
Alternatively, you can also use Value Function to convert strings into Numeric datatype within your DAX.
Flag =
VAR _Cond1 =
IF (
'DW C, S & Comp (2)'[x FD Email Address] <> "FD"
&& (
AVERAGE ( VALUE('DW C, S & Comp (2)'[Number Of Orders]) ) >= 4
&& AVERAGE ( VALUE('DW C, S & Comp (2)'[Number Of Orders]) ) <= 7
)
&& SUM ( VALUE('DW C, S & Comp (2)'[Complaint Amount] )) >= 230
&& SUM ( VALUE('DW C, S & Comp (2)'[Comp_OrderID] )) >= 3
&& 'DW C, S & Comp (2)'[Yesterday Flag] = "Y",
"Yes",
"No"
)
VAR _Cond2 =
IF (
'DW C, S & Comp (2)'[x FD Email Address] <> "FD"
&& 'DW C, S & Comp'[Credit % Subtotal] >= 0.24
&& (
SUM ( VALUE('DW C, S & Comp (2)'[Number Of Orders]) ) >= 8
&& SUM ( VALUE('DW C, S & Comp (2)'[Number Of Orders]) ) <= 9
)
&& SUM ( VALUE('DW C, S & Comp (2)'[Comp_OrderID]) ) >= 3
&& 'DW C, S & Comp (2)'[Yesterday Flag] = "Y",
"Yes",
"No"
)
VAR _Cond3 =
IF (
'DW C, S & Comp (2)'[x FD Email Address] <> "FD"
&& 'DW C, S & Comp'[Credit % Subtotal] >= 0.22
&& (
SUM ( VALUE('DW C, S & Comp (2)'[Number Of Orders]) ) >= 10
&& SUM ( VALUE('DW C, S & Comp (2)'[Number Of Orders]) ) <= 14
)
&& SUM ( VALUE('DW C, S & Comp (2)'[Comp_OrderID]) ) >= 3
&& 'DW C, S & Comp (2)'[Yesterday Flag] = "Y",
"Yes",
"No"
)
VAR _Cond4 =
IF (
'DW C, S & Comp (2)'[x FD Email Address] <> "FD"
&& 'DW C, S & Comp'[Credit % Subtotal] >= 0.2
&& SUM ( VALUE('DW C, S & Comp (2)'[Number Of Orders]) ) >= 15
&& SUM ( VALUE('DW C, S & Comp (2)'[Comp_OrderID]) ) >= 3
&& 'DW C, S & Comp (2)'[Yesterday Flag] = "Y",
"Yes",
"No"
)
RETURN
IF (
_Cond1 = "Yes"
|| _Cond2 = "Yes"
|| _Cond3 = "Yes"
|| _Cond4 = "Yes",
"Yes",
"No"
)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
42 | |
33 | |
30 | |
18 | |
18 |