Summary type Sum is not appropriate for column of type System.String error - asp.net

I am getting this error whenever I try to run my project although the column isn't of type system.string. I have a page that is coded the same way with different numbers and it doesn't give me this error. This is my SQL string:
MyCompSqlString = "SELECT (KAIPRDDTA.F4102LA.IBPRP6)ColOne, (KAIPRDCOM.F0005.DRDL01)ColTwo, COUNT(KAIPRDDTA.F42119LA.SDSOQS*.01)ColThree, SUM(KAIPRDDTA.F42119LA.SDAEXP*.01*CXCRR)ColFour, count(SDDOC)ColFive, SUM(KAIPRDDTA.F42119LA.SDSOQS*.01)ColSix "
MyCompSqlString += "FROM KAIPRDDTA.F42119LA, KAIPRDDTA.F55311, KAIPRDCOM.F0005, KAIPRDDTA.F0015, KAIPRDDTA.F4102LA"
MyCompSqlString += "WHERE DRSY = '41' AND DRRT = '01' AND TRIM(DRKY) = IBPRP6 AND KAIPRDDTA.F42119LA.SDITM = KAIPRDDTA.F4102LA.IBITM AND KAIPRDDTA.F42119LA.SDMCU = KAIPRDDTA.F4102LA.IBMCU AND KAIPRDDTA.F42119LA.SDSLSM = KAIPRDDTA.F55311.TERR AND (KAIPRDDTA.F42119LA.SDIVD >= " & SDJ & ") AND (KAIPRDDTA.F42119LA.SDIVD <= " & EDJ & ") AND "
MyCompSqlString += "(KAIPRDDTA.F42119LA.SDSLSM > 0) AND (KAIPRDDTA.F42119LA.SDGLC NOT IN ('FT60', 'TXTX', 'IN20', 'INSP', 'INWC', 'INWR', 'INWS','',' ')) AND "
MyCompSqlString += "(trim(KAIPRDDTA.F42119LA.SDLNTY) NOT IN ('T', 'F', 'TX', 'TA', 'TS', 'RF', 'RP','BC')) AND (KAIPRDDTA.F42119LA.SDNXTR <> '999') AND (KAIPRDDTA.F42119LA.SDDCTO not in ('ST','CR','SR')) "
MyCompSqlString += "AND (KAIPRDDTA.F55311.VIEWID = '" & MyView & "') AND (SDAN8 <> 24157 and SDAN8 <> 152) AND ((SDTRDJ-1)=CXEFT) AND (SDBCRC=CXCRCD) AND (CXCRDC ='USD')"
MyCompSqlString += "GROUP BY KAIPRDDTA.F4102LA.IBPRP6, KAIPRDCOM.F0005.DRDL01"
and this is my summary row:
<ig:SummaryRow EmptyFooterText="" FormatString=" {1}" ShowSummariesButtons="false">
<ColumnSummaries>
<ig:ColumnSummaryInfo ColumnKey="ColThree">
<Summaries>
<ig:Summary SummaryType="Sum" />
</Summaries>
</ig:ColumnSummaryInfo>
<ig:ColumnSummaryInfo ColumnKey="ColFour">
<Summaries>
<ig:Summary SummaryType="Sum" />
</Summaries>
</ig:ColumnSummaryInfo>
<ig:ColumnSummaryInfo ColumnKey="ColFive">
<Summaries>
<ig:Summary CustomSummaryName="100.00%" />
</Summaries>
</ig:ColumnSummaryInfo>
<ig:ColumnSummaryInfo ColumnKey="ColTwo">
<Summaries>
<ig:Summary CustomSummaryName="Totals:" />
</Summaries>
</ig:ColumnSummaryInfo>
</ColumnSummaries>
Does anyone have any suggestions as to why it is giving me this error? Let me know if you need any more information and I will update my question. Thanks in advance for your responses

You have a group which is NULL. This error means not all of the values are integer. So this query must produce a NULL as a value on some of the rows.

Related

How do I prevent Application.Match Function giving me a Run-Time Error 91?

I'm trying to find a match in a column, return the range of that match, then display a message box with values derived from cells offset from that match's range. But I get error code 91 when I run this. I'm not a great coder, so any extra details you can provide would be really appreciated, as sometimes I struggle to understand the answers provided if it's too jargony.
I was using the find function, but occasionally, the match I want to find is hidden via filters in the spreadsheet, and I read somewhere that the match function won't be affected by whether the cells are filtered or not.
Sub GetInfo2()
Dim Item As String
Dim FindRng As Range
Item = InputBox("What is the item number?", "Item Number")
FindRng = Application.Match(Item, Worksheets("Current Week Summary").Columns(1), 0)
If Not FindRng Is Nothing Then
MsgBox ("Description: " & FindRng.Offset(0, 4).Value & vbCrLf & _
"Flyer/FEM: " & FindRng.Offset(0, 1).Value & vbCrLf & _
"Margin Maker: " & FindRng.Offset(0, 2).Value & vbCrLf & _
"ISR Week: " & FindRng.Offset(0, 3).Value & vbCrLf & _
"Amount To Sell: " & Round(FindRng.Offset(0, 7).Value, 0) & vbCrLf & _
"Cost: $" & FindRng.Offset(0, 18).Value & vbCrLf & _
"Months of Supply: " & Round(FindRng.Offset(0, 35).Value, 0) & vbCrLf & _
"E&O Qty: " & FindRng.Offset(0, 17)), vbOKOnly, Item
End If
End Sub
I did overcome the issue of not being able to search in filtered rows. I ended up using the VLookup Function to find my matches. It apparently searches whether it's filtered or not. I'm still stumped on how to use the match function, so I'd love to know how to do that. But this solved my problem in the interim.
Sub GetInfo()
Dim Item As String
Dim Description As String
Dim FlyerFEM As String
Dim MargMak As String
Dim ISR As String
Dim ATS As String
Dim Cost As String
Dim Supply As String
Dim EAO As String
Item = InputBox("What is the item number?", "Item Number")
Description = WorksheetFunction.VLookup(Item, Range("A:AJ"), 5, False)
FlyerFEM = WorksheetFunction.VLookup(Item, Range("A:AJ"), 2, False)
MargMak = WorksheetFunction.VLookup(Item, Range("A:AJ"), 3, False)
ISR = WorksheetFunction.VLookup(Item, Range("A:AJ"), 4, False)
ATC = WorksheetFunction.VLookup(Item, Range("A:AJ"), 8, False)
Cost = WorksheetFunction.VLookup(Item, Range("A:AJ"), 19, False)
Supply = WorksheetFunction.VLookup(Item, Range("A:AJ"), 36, False)
EAO = WorksheetFunction.VLookup(Item, Range("A:AJ"), 18, False)
MsgBox ("Description: " & Description & vbCrLf & _
"Flyer/FEM: " & FlyerFEM & _
"Margin Maker: " & MargMak & vbCrLf & _
"ISR Week: " & ISR & vbCrLf & _
"Amount To Sell: " & Round(ATC, 0) & vbCrLf & _
"Cost: $" & Cost & vbCrLf & _
"Months of Supply: " & Supply & vbCrLf & _
"E&O Qty: " & Round(EAO, 0)), vbOKOnly, Item
End Sub

DAX formula to show not repeated values and count them

I have a table with for which the column "CODE" has values like this:
FTRA2
BRB92
RBRB4
XYZ
SXM4
RBRB4
NLDR
XYZ
FTRA2
POEU
FTRA2
I currently have this formula
="[ Unique values " & DISTINCTCOUNT(MyTable[CODE]) & "]
" & CONCATENATEX(DISTINCT(MyTable[CODE]), MyTable[CODE] ,", ")
that outputs this:
[ Unique values 7 ]
FTRA2, BRB92, RBRB4, XYZ, SXM4, NLDR, POEU
I would like to show all the unique values and their count (except those with the string "XYZ") and below show how many "XYZ" values are, like this:
[ Unique values 6 ]
FTRA2, BRB92, RBRB4, SXM4, NLDR, POEU
[2 XYZ values]
In this case there are 2 "XYZ" values, but could be zero XYZ values too.
I'm using Excel 2016.
How can I do this? Thanks in advance.
UPDATE1
I get this error tryng Joe's solution.
UPDATE2
Joe, I was able to make work your first part modifying like this:
= VAR ExcludeValue = "XYZ"
RETURN
CALCULATE(
"[ Unique values " & DISTINCTCOUNT(MyTable[Code]) & " ]"
" & CONCATENATEX(DISTINCT(MyTable[Code]), [Code], ", ")
, MyTable[Code] <> ExcludeValue
)
But when I add the second part it says this error
This formula is invalid or incomplete: 'Calculation error in
measure 'MyTable[Code]: The function COUNT takes an argument
that evaluates to numbers or dates and cannot work with values
of type String.'.
I also removed the UNICHAR since doesn't work on Excel.
UPDATE3
Joe's solution it works correctly after I modified the COUNT(MyTable[Code]) to COUNTROWS(MyTable)
The final solution looks like this.
=VAR ExcludeValue = "XYZ"
RETURN
CALCULATE(
"
[ Unique values " & DISTINCTCOUNT(MyTable[Code]) & " ]
" & CONCATENATEX(DISTINCT(MyTable[Code]), [Code], ", ")
, MyTable[Code] <> ExcludeValue
) & "
" & CALCULATE(
"[" & COUNTROWS(MyTable) & " " & ExcludeValue & " values]"
, MyTable[Code] = ExcludeValue
) & "
"
Update4
Print nothing when there is no "XYZ" values works with your IF() addition. I've tried to follow your logic to do the same when there is no values at all. I added an
IF() to count if MyTable[Code] <> ExcludeValue is greater than 0 and if true do original CALCULATE, if not BLANK() but doesnt work.
CountLabel =
VAR ExcludeValue = "XYZ"
RETURN
IF(
CALCULATE(COUNTROWS(MyTable), MyTable[Code] <> ExcludeValue) > 0,
CALCULATE(
"[ Unique values " & DISTINCTCOUNT(MyTable[Code]) & " ]"
& UNICHAR(10) &
CONCATENATEX(DISTINCT(MyTable[Code]), [Code], ", ")
, MyTable[Code] <> ExcludeValue
),
BLANK()
)
& IF(
CALCULATE(COUNTROWS(MyTable), MyTable[Code] = ExcludeValue) > 0,
UNICHAR(10) & " " & UNICHAR(10) &
CALCULATE(
"[" & COUNTROWS(MyTable) & " " & ExcludeValue & " values]"
, MyTable[Code] = ExcludeValue
),
BLANK()
)
FINAL UPDATE
This is the final formula that works as expected. Thanks to Joe's help in this case.
=VAR ExcludeValue = "XYZ"
RETURN
IF(
CALCULATE(DISTINCTCOUNT(MyTable[Code]), MyTable[Code] <> ExcludeValue) > 0 &&
MyTable[Count of Code]>0,
CALCULATE(
"
[ Unique values " & DISTINCTCOUNT(MyTable[Code]) & " ]
" & CONCATENATEX(DISTINCT(MyTable[Code]), [Code], ", ")
, MyTable[Code] <> ExcludeValue
),
BLANK()
)
&
IF(
CALCULATE(DISTINCTCOUNT(MyTable[Code]), MyTable[Code] <> ExcludeValue) > 0 &&
CALCULATE(COUNTROWS(MyTable), MyTable[Code] = ExcludeValue) > 0,
"
" &
BLANK()
)
& IF(
CALCULATE(COUNTROWS(MyTable), MyTable[Code] = ExcludeValue) > 0,
CALCULATE(
"[" & COUNTROWS(MyTable) & " " & ExcludeValue & " values]"
, MyTable[Code] = ExcludeValue
),
BLANK()
) & "
"
UPDATE: - Changed my formula from using COUNT to COUNTROWS based on feedback from OP.
UPDATE 2: - Add IF statement to formula to exclude excluded count when 0.
UPDATE 3: - Add IF statement to formula to exclude distinct count when 0.
I will say that I created this solution in Power BI, but Excel 2016 should have the same functionality when it comes to DAX (with minor tweaks).
I created a measure with your formula, and simply wrapped each piece (the distinct count, and the repeated count) with a CALCULATE statement that is used to filter your MyTable down to the codes you care about.
I used a variable for the "XYZ" value in case that needs to be changed. Now you can simply change it in one place (at the beginning of the formula) and the rest of the formula will reflect that change.
I also used UNICHAR(10) to add the line breaks instead of counting on the new lines in the formula.
With the IF statements...
The first will check if the distinct count of items not equal to the specified value is greater than zero. If not, it won't show anything.
The second will check if the distinct count and the row count of the specified value are both greater than zero. If they are, it will add the line break.
The third will check if the row count of items equal to the specified value is greater than zero. If not, it won't show anything.
The final formula is:
CountLabel =
VAR ExcludeValue = "XYZ"
RETURN
IF(
CALCULATE(DISTINCTCOUNT(MyTable[Code]), MyTable[Code] <> ExcludeValue) > 0,
CALCULATE(
"[ Unique values " & DISTINCTCOUNT(MyTable[Code]) & " ]"
& UNICHAR(10) &
CONCATENATEX(DISTINCT(MyTable[Code]), [Code], ", ")
, MyTable[Code] <> ExcludeValue
),
BLANK()
)
&
IF(
CALCULATE(DISTINCTCOUNT(MyTable[Code]), MyTable[Code] <> ExcludeValue) > 0 &&
CALCULATE(COUNTROWS(MyTable), MyTable[Code] = ExcludeValue) > 0,
UNICHAR(10) & " " & UNICHAR(10),
BLANK()
)
& IF(
CALCULATE(COUNTROWS(MyTable), MyTable[Code] = ExcludeValue) > 0,
CALCULATE(
"[" & COUNTROWS(MyTable) & " " & ExcludeValue & " values]"
, MyTable[Code] = ExcludeValue
),
BLANK()
)
Here is what the result looks like (again, in Power BI).
Came up with something similar but slightly different using COUNTROWS instead of CALCULATE to filter the table for the unique item. Also I am just learning DAX so don't know if this is a "proper" way to do it, but it seems to work.
Measure =
VAR Exclusion = "XYZ"
RETURN
"[ Unique values " & COUNTROWS(FILTER(DISTINCT(MyTable[CODE]), [CODE] <> Exclusion)) & "]
" & CONCATENATEX(FILTER(DISTINCT(MyTable[CODE]), [CODE] <> Exclusion), [CODE] ,", ") &
"
[" & COUNTROWS(FILTER(MyTable, MyTable[CODE] = Exclusion))+0 & " " & Exclusion & " values]"

Cannot use insert statement in asp.net

Please someone advise me. I am trying to make some error log in DB. I am writing the below query to insert data to table having 2 filednames only.
But I am getting error as:
Error starting at line : 1 in command -
INSERT INTO QISWEBLOG (DATETIME, MESSAGE) VALUES (
'2017/12/24 01:01:48',
Status ='0' INSPECTOPERATOR = '122018 ' INSPECTDATETIME = [20171201040930] MANAGEOPERATOR = [MIS] MANAGEDATETIME = [20171224130133] [StockGumUpdate Barcode] = [21T399--A02 BU60212CTBSID0]
)
Error at Command Line : 4 Column : 8
Error report -
SQL Error: ORA-00917: missing comma
00917. 00000 - "missing comma"
*Cause:
*Action:
My query is:
Dim text1 As String
text1 = "Status = '" & status & "' INSPECTOPERATOR = '" & inspectOperator & "' INSPECTDATETIME = '" & inspectDateTime & "' MANAGEOPERATOR = '" & manageOperator & "' MANAGEDATETIME = '" & manageDateTime & "' [StockGumUpdate Barcode] = '" & GridView1.Rows(index).Cells(1).Text & "'"
sqlStr = "INSERT INTO QISWEBLOG (DATETIME, MESSAGE)"
sqlStr = sqlStr & " VALUES ('" & Trim(CStr(Format(DateTime.Now,
"yyyy/MM/dd hh:mm:ss"))) & "','" & text1 & "')"
Please help where I am wrong.
You need to skip (or escape) all the single quotes in your text1 variable. To escape a single quote, you need to type it twice.
Status =''0'' etc...

syntax error in SQL Update statement

I'm getting a syntax error in my UPDATE statement, but I'm not sure where exactly it is. Here's my code:
strSelected = "UPDATE CFRRR SET assignedby = " & Me.cmbassignedby.Column(1) & ", assignedto = " & _
Me.cmbassignedto.Column(2) & ", Dateassigned = " & Now() & ", actiondate = " & _
Now() & ", Workername = " & Me.cmbassignedto.Column(2) & ", WorkerID = " & _
Me.cmbassignedto.Column(1) & " WHERE CFRRRID In ( " & strSelected & " );"
CurrentDb.Execute strSelected
It's most likely because of the Now() function, which also prints the current time (seperated with a space) - hence the syntax error. Try to surround them with single quotation marks.
You can also print out the SQL Statement
Debug.Print strSelected to see what you have concatenated...

Error in setting LinqDataSource Where Clause with datetime column

i want to set the following linqdatasource where clause in code behind.
<asp:LinqDataSource ID="lds" runat="server" ContextTypeName="dcDataContext"
TableName="vStaff_Currents" OrderBy="Department,DisplayName" >
</asp:LinqDataSource>
in code behind:
Dim filterString As String = ""
Dim AtDate As Date = Nothing
AtDate = Request("PeriodEnd").ToDate
filterString = "xxxxxxxxxxx"
filterString = filterString & "xxxxxxxxxxx"
lds.Where = filterString
i want to Insert datetime condition in where clause from querystring [Request("PeriodEnd")]
i had tried different command, but it returns error
Option 1:
filterString = filterString & " and (RenumerationDate <= DateTime.Parse(" & AtDate & "))"
Error:
No applicable method 'Parse' exists in type 'DateTime'
Option 2:
filterString = filterString & " and (RenumerationDate <= " & AtDate.ToString("dd-mm-yyyy") & " )"
Error:
Operator '<=' incompatible with operand types 'DateTime?' and 'Int32'
How can I add the where clause in code behind ? Thanks
The solution is:
filterString = filterString & " and (RenumerationDate <= DateTime.Parse(""" & AtDate & """))"
Try this way
filterString = filterString & " and (RenumerationDate <= " & DateTime.Parse(AtDate) & ")"
or
filterString = filterString & " and (RenumerationDate <= " & Convert.ToDateTime(AtDate) & ")"

Resources