I have a table in ssms and on using the case statement, it is working as expected as shown:
ssms_case_statement
But doing the same thing in Power BI with adding columns, conditional statement, it is not working as expected. The screenshot is below. I am stuck here. Please help me out.
Power BI case statement issue
then [Value] * 100 else [Value]
Related
I would like to get some data from SQL server to Excel. I want to make a calculation at query, but I get a syntax error.
How can I make this calculation?
SELECT .........
..........,
((SX.AP)-(SX.US*SX.UG))/2.1 AS MARGIN
,..........
FROM ....
finally found this works ;
(SX.AP/2.1-SX.US/2.1*SX.UG) AS MARGIN,
I am running queries on an Intersystems Cache database via an ODBC connection. It had been working perfectly up until a couple of hours ago when sending a statement like SELECT COUNT(*) FROM cmr_table started to return 0. The statement SELECT * FROM cmr_table returns plenty of rows and seems to work as normal.
Any help is greatly appreciated!
Looks like, you added new index. Try to rebuild all indices in your class.
do ##class(your.class).%BuildIndices()
When I run a select query on an informix database using Teradata Sql Assistant all the text fields are null. But when I use another database manager like DBeaver, using a select query on the same table, I get values in the text fields. Has anyone else encountered this issue? if yes, how did you fixed it?
Thanks for the help!
I had similar issues today, try converting the text column to varchar in your select.
SELECT CAST(txt_column As VARCHAR(8000))
I am having a an issue with SQL Command and CASE. I am pretty new to Crystal Reports/SQL and I have a basic code that I am playing around with to learn. I want to clean out a field -- that has imported from SQL Server. I just want to do something simple like this:
SELECT "I"."I_TYPE", "Alleg” =
CASE
WHEN "ALLEGs"."ALLEG” LIKE ‘*im*’ THEN ‘Improper’
ELSE ‘UNKNOWN’
END
I get an error that says Database Connector Error:
'42000:[MS][SQL..Incorrect syntax near ' . ' . Databse vender code 102.
Can you even use CASE as an IF THEN statement in the SQL Command. I am aware of SQL expressions, but I am trying to pull data to sql command to prevent performance decrease.
I am not sure about crystal report but your query formation don't look correct. It should be
SELECT I.I_TYPE,
CASE WHEN ALLEGs.ALLEG LIKE '%im%' THEN 'Improper' ELSE 'UNKNOWN' END AS 'Alleg'
Rahul, is correct for direct SQL commands to the server.
However sometimes when running Crystal Reports we use VBA within the report to do some data tuning rather than modifying the raw SQL on the fly.
This leaves the raw SQL a known result (verifiable on the SQL Server) and then modify the output in Crystal to fit the end users filtering requirements.
This is not efficient with large result sets but when the results are smaller (under 50k records) we usually have our team go with simple (post filtering) to reduce design and testing time.
This technique works very well with dynamic filters on the option section.
example: [Record Selection]
if {?Select Sales Person} <> "ENT" then
{R0033___P2A.ProjectionSP} = {?Select Sales Person} and {R0033___P2A.FM} >= 0
else
{R0033___P2A.ProjectionSP} > "" and {R0033___P2A.FM} >= 0
Where {?Select Sales Person} is a user selection filter and {R0033___P2A} is a predefined report view or stored procedure.
is there a better way to display simple grid (looking basically like SQL select statement) from SSAS cube using MDX command instead of using this Drillhrough workaround?
Here is what I've been using so far:
DRILLTHROUGH
Select
([Measures].[Some Measure]) on columns
From (
Select
{
[PeriodSpan].&[201301] : [PeriodSpan].&[201304]
}
on columns
From [CubeName]
)
RETURN
[$Dimension1].[Attribute1],[$Dimension1].[Attribute2],[$Dimension1].[Attribute3],[$Dimension1].[Attribute4],[$Dimension1].[Attribute5],
[$Dimension2].[Attribute1],[$Dimension2].[Attribute2],[$Dimension2].[Attribute3],
[$Dimension3].[Attribute1],[$Dimension3].[Attribute2],[$Dimension3].[Attribute3],[$Dimension3].[Attribute4],
IIF([Dimension4].[Attribute1]=[Dimension4].[Attribute1].&[False],[Dimension4].[Attribute2],[Dimension4].[Attribute3])
Problem is that now I can't figure out how to get IFF condition to work. When I try to run the command error message appears saying "Too many arguments were passed to the IIF MDX function. No more than 1 arguments are allowed." I also tried to create new member on cube level by calculation script:
SCOPE (some hierarchy here which I'm still not clear on how to use);
IF [$Dimension4].[Attribute1] IS [$Dimension4].[Attribute1].&[False] THEN this = [Dimension4].[Attribute2] END IF;
IF [$Dimension4].[Attribute1] IS [$Dimension4].[Attribute1].&[True] THEN this = [Dimension4].[Attribute3] END IF;
END SCOPE
I also tried calculated member and named set but with no results.
I'm fairly new to SSAS and MDX but I hope you see what I'm trying to accomplish. Thanks in advance. Any help would be much appreciated.