The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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"
)
User | Count |
---|---|
27 | |
10 | |
8 | |
7 | |
5 |
User | Count |
---|---|
33 | |
13 | |
11 | |
9 | |
8 |