I have 3 columns and here are 2 possible ways:
1. In all of them are values
2. Only col1 keeps value (col2 and col3 NULL)
For now It looks like:
| col1 | col2 | col3 |
----------------------
| val1 | | |
| val2 | val3 | val4 |
| val5 | val6 | val7 |
| val8 | | |
It should be like this:
| col1 | col2 | col3 |
----------------------
| val1 | -- merged cells, because col2 and col3 empty
| val2 | val3 | val4 |
| val5 | val6 | val7 |
| val8 | -- merged cells, because col2 and col3 empty
I don't have idea If I need to create groups (I've tried row/column grouping, but really unsuccessfully, far away from what I need).
As I think I need to write expression something like:
IFF(col2 & col3 = NULL) MERGE(col1, col2, col3)
Just I can't get success with expression's structure.
I don't think in SSRS it is possible to merge cells dynamically using expressions. Only way I can think of is having a fourth text box(Probably below the 3 on top) which contains the Col1, Col2 and Col3 in a concatenated fashion. Then you can set the condition for visibility on these two sets of textboxes. i.e. If Col2 and Col3 are NULL, hide the top 3 text boxes and make the fourth visible. On the other hand if Col2 or Col3 are not NULL, show the top 3 and hide the fourth one.
I think that you can do this by using an expression for each of the cells in a row like this:
Column 1:
=iif(isNothing(col2) AND isNothing(col3), "", col1)
Column 2:
=iif(isNothing(col2) AND isNothing(col3), col1, col2)
Column 3:
=iif(isNothing(col2) AND isNothing(col3), "", col3)
This sort of bypasses the need to merge, which should be faster and easier to implement.
Can you try IsNothing instead of = NULL ?
EX: =IIF(IsNothing(Fields!MyField.Value),Fields!MyFields.Value,Fields!MyFields.Value)
If needed use IIF condition again...
Related
After a lot of google search, I got an example on merging Header columns and adding rows as per my requirement but it is c1flexgird code I am not able to convert in WPF main form.
https://www.grapecity.com/componentone/docs/wpf/online-flexgrid/MultipleCellRow.html
My data structure also like
col1 | col1 | col2 | col2 | col3 | col3
and I want add rows like below
col1 | Col2 | col3
A | B | A | B | A | B
Please have a look on my issue to fix my problem. Thanks
I am trying to set up a table in markdown that I can store in a Gitlab Wiki.
The table looks something like this:
| Col1 | Col2 | Col 3 | Col4 |
| :---: | :---: | :---: | --- |
| ID1 | Yes | No | some text |
Here is how the table looks:
Col1
Col2
Col 3
Col4
ID1
Yes
No
some text
What I would like to do instead of editing and changing the cell to be Yes or No manually, that I could use a checkbox, normally "- [ ]" should work but apparently does not work inside of table.
I need to merge some column value into one column with varchar/nvarchar data type.
I tried to use Computed Column Specification in Table Designer, but I only know how to compute int data type.
| Column1 | | Column2 | | Column3 | |MergedColumn|
| A | | B | | C | | AB-C |
| A1 | | B1 | | C1 | | A1B1-C1 |
I need that result in MergedColumn.
The CONCAT function should work here:
SELECT
Column1,
Column2,
Column3,
CONCAT(Column1, Column2, '-', Column3) AS MergedColumn
FROM yourTable;
I am trying to unpivot a large dataset, with 250 columns. There is a very good documented solution here unpivot and PostgreSQL.
However, it inputs the column names manually. I'm looking to do something like..
extract all column names into an array
pass the array through unnest
OR,
extract all column names into an array
loop the array by indexing through
using column name values as an input in the unnest
Apologies for being noob, New to SQL!
This dataset is good enough for purposes:
CREATE TEMP TABLE foo (id int, a text, b text, c text);
INSERT INTO foo VALUES (1, 'ant', 'cat', 'chimp'), (2, 'grape', 'mint', 'basil');
SELECT id,
unnest(array['a', 'b', 'c']) AS colname,
unnest(array[a, b, c]) AS thing
-- I would like something like.. unnest(array[column_names]) AS thing
-- where column_names = [a,b,c.. so on]
FROM foo
ORDER BY id;
Expected outcome:
id | colname | thing
1 | a | ant
1 | b | cat
1 | c | chimp
2 | a | grape
2 | b | mint
2 | c | basil
Use JSONB functions, example:
select id, key as colname, value as thing
from foo t
cross join jsonb_each_text(to_jsonb(t)- 'id')
id | colname | thing
----+---------+-------
1 | a | ant
1 | b | cat
1 | c | chimp
2 | a | grape
2 | b | mint
2 | c | basil
(6 rows)
We have a report store with a denormalised flat table that stores identical data to a multi-table model in a different database.
Flat table (example):
| col 1 | col 2 | col 3 | timestamp |
|-------|-------|-------|-----------|
| val1 | val2 | val3 | 1/1/1990 |
| val1 | val9 | val3 | 1/1/1990 |
In multiple tables:
| id1 | id2 | timestamp |
|-----|-----|-----------|
| 001 | 111 | 1/1/1990 |
| 001 | 112 | 1/1/1990 |
| id1 | col 1 | col 3 |
|-----|-------|-------|
| 001 | val1 | val3 |
| id2 | col 2 |
|-----|-------|
| 111 | val2 |
| 112 | val9 |
There are several old reporting queries that we would like to port over to the new flat table without having to rewrite them all up front - there are many of them and they are complex.
Is there a way of writing Views that can simulate a set of relational tables from the single flat table, so that the old reporting queries work without modification?
HereI create dynamical IDs. You could also initialy make that table with fix keys, and always when adding or removing a row in the flattable do the same with the key here. Otherwise instead of Groub by use the OVER statement.
CREATE VIEW multitabkey AS
SELECT ROW_NUMBER() as key, col1, col3
FROM flattable
Group by col1, col3
WARNING: those keys are not persistent: if you delete the first row, all others get their id one smaler than before. You have dynamic IDs, but they are consistnet.
If you have a translation for your Keys you can use them as following:
CREATE VIEW multitabone AS
SELECT f.timestamp
FROM flattable as f
JOIN multitabkey as m ON m.col1 = f.col1 AND m.col3 = f.col3
Group by col1, col3
I assumed col1 , col2 are together a natural key.
As mentioned, this is a workaround, your DB is not in 3rd normalform what can cause inconsistency.