This is my crosstab :
ColumnA ColumnB
X D
Y E
Z F
I want it to be converted to :
ColumnA X Y Z
ColumnB D E F
I checked all the properties and checked for CSS but did not find anything on this topic!
Select your original table in webi report, right click the block, select "Turn into " option, then select "Horizontal Table" option. You will get the expected result.
Related
Below is my query from which I'm excluding some characters from query. It's working for me.
SELECT
b.TRANS_DETAILS_ID,
b.DEBIT_AMOUNT,
b.ENTITY_NAME,
REPLACE(b.DESCRIPTION, 'SP Z O.O.', '') AS DESCRIPTION,
DATE_FORMAT(a.TRANSACTION_DATE_TIME, '%d-%m-%Y') AS TRANS_DATE
FROM bank_book_transaction_master a,
bank_book_transaction_details b
WHERE a.TRANSACTION_DATE_TIME
BETWEEN '$from_date_srch' AND '$to_date_srch'
AND DEBIT_CREDIT_FLAG = 2
AND a.ORG_ID = '$org_id'
AND a.BANK_ID = '$bank_id'
AND a.TRANSACTION_ID = b.TRANS_MASTER_ID
But my problem is in my database SP Z O.O. these characters are storing differently sometimes. In some columns it's SP Z O.o. or sp z O.O. or SP Z O.O.. My query removes only if charaters are similar like SP Z O.O.. But I want to add all conditions like small letters whitespace etc.
I tried with LIKE %SP Z O.O.% but it shows me result in 1 and 0.
I Have a list of My SQL files with the following names. These are located in a folder whose path is reportconnection (reportconn)
TableName
A1_1
A1_2
A1_3
A1_4
A1_5
A1_6
A1_7
A1_8
Each of these tables consists of data regarding 1 e mail campaign blast.
The structure of each of these is as follows. There are 8 such tables, one for each e mail campaign
C1 C2 C3
Y X Z
Y2 X2 Z2
I want a list of unique counts of C2 for each A1, A2, A3 etc.
I have used the following code
C2count<-list()
For (I in(Tablenames){
sql2 <- paste("select count(DISTINCT BINARY C2) from ", TableName)## SQL
Query
C2count<-rbind(C2count,dbGetQuery(reportconn, sql2).}
I am getting just a single list of values. Please help me.
Your sql2 is pasting in "Tablenames" instead of I. I is looping through each name in your list of Tablenames. I is what is changing each time. Hope this helps.
` C2count<-list()
For (I in Tablenames){
sql2 <- paste("select count(DISTINCT BINARY C2) from ", I)## SQLQuery
C2count<-rbind(C2count,dbGetQuery(reportconn, sql2)
}`
I've forgotten whatever I used to know about pivots, but this seems to me the reverse. Suppose I have a set of items A, B, C, D, … and a list of attributes W, X, Y, Z. I have in a spreadsheet something like
A B C D
W 1 P 3 Q
X 5 R 7 S
Y T 2 U 4
Z D 6 F 7
where the value of attribute X for item B is 'P'. In order to do some statistics on comparisons, I'd like to change it from table to list, i.e.,
W A 1
X A 5
Y A T
Z A D
W B P
X B R
Y C U
Z C F
W D Q
X D S
Y B 2
Z B 6
Etc.
I can easily write a nested loop macro in the spreadsheet to do it, but is there an easy way to import it into mySQL in the desired format? Queries to get the statistics needed are simple in SQL (and formulas not very hard in a spreadsheet) if the data is in the second format.
Since there apparently isn't a "spreadsheet" tag, I used "excel." :-)
There are a lot of questions that looked similar at first glance, but the five I looked at all wanted to discard one of the indices (A-D or W-Z), i.e. creating something like
W 1
W P
X 5
X R
EDITED
You can use PowerQuery to unpivot tables. See the answer by teylyn for the following question. I have Office 365 and didn't need to install the plugin first. The functionality was already available.
Convert matrix to 3-column table ('reverse pivot', 'unpivot', 'flatten', 'normalize')
Another way to unpivot data without using VBA is with PowerQuery, a free add-in for Excel 2010 and higher, available here: http://www.microsoft.com/en-us/download/details.aspx?id=39379
...
Click the column header of the first column to select it. Then, on the Transform ribbon, click the Unpivot Columns drop-down and select Unpivot other columns.
...
OLD ANSWER
If you import the spreadsheet as is, you can run a query to output the correct format.
For a fixed, small number of items, you can use UNION for each of the columns.
SELECT attr, 'A' AS 'item', A AS 'value'
FROM sheet
UNION
SELECT attr, 'B' AS 'item', B AS 'value'
FROM sheet
UNION
SELECT attr, 'C' AS 'item', C AS 'value'
FROM sheet
UNION
SELECT attr, 'D' AS 'item', D AS 'value'
FROM sheet;
Working example: http://sqlfiddle.com/#!9/c274e7/7
I have a problem with duplicates.
Actually what I need is only the see duplicates but my table has many variables something like the below:
a b c d e
32 ayi dam som kem
32 ayi dam som tws
32 ayi dam tsm tws
12 mm ds de ko
12 mm tmm to ko
I am trying to keep if 'a' 'b' 'c' and 'd' variables are same. So I need only first 2 columns. I try to do this
proc sort data=al nodupkey dupout=dups;
by a b c d;
run;
any idea if this works?
In SAS 9.3+ you can do this very easily with the new nouniquekey option.
proc sort data=have nouniquekey out=want;
by a b c d;
run;
That removes any rows which are unique and leaves duplicates.
If you have an earlier version of SAS, you can do something fairly simple after a regular sort.
So, after sorting as in your example above but without nodupkey:
data want;
set have;
by a b c d;
if not (first.d and last.d);
run;
That removes records that are the first AND last record based on a b c d.
Another option could be Proc SQL, no pre-sort needed:
proc sql;
create table want as
select * from have
group by a, b, c, d
having count(*)>1; /*This is to tell SAS only to keep those dups*/
quit;
Each record in my report includes (amongst other information) a set of other data items of the format "ItemName X Y Z" where X, Y & Z are numerical values.
When displayed this set will be grouped (as illustrated below) according to a properties of each item, and displayed in a table or similar.
The values X, Y and Z will be displayed pictorially and formatting will be applied to other items (i.e. background colours applied to different group names) to make the information easier to read.
What would be the best way to display this in a report? Current options seem to be using either Sub Reports or to build a new control using CustomReportItems.
Level 1 Group 1 Name
Level 2 Group 1.1 Name
ItemName X Y Z
ItemName X Y Z
ItemName X Y Z
Level 2 Group 1.2 Name
ItemName X Y Z
ItemName X Y Z
ItemName X Y Z
Level 1 Group 2 Name
Level 2 Group 2.1 Name
ItemName X Y Z
ItemName X Y Z
ItemName X Y Z
Level 2 Group 2.2 Name
ItemName X Y Z
ItemName X Y Z
ItemName X Y Z
From my understanding of the requirements, all of this can be achieved in a single table (or list) object, without requiring subreports:
Set up your data query.
Insert a table object into the report, with the dataset specified as the dataset for the query.
Insert groups into the reports for each of the Level 1 and Level 2 grouping criteria. Include group header sections, but not group footers.
To format a cell's colour based on a data item in the detail section (ie. at ItemName X Y Z level), select that cell in the Report Designer and set the BackgroundColour property (from the Properties window) to be an expression selecting the desired colour, using the Edit Expression dialog. (Immediately below the BackgroundColour property is a BackgroundImage property, which can also be set using an expression, if you want to use specific images rather than colours.)