Using MDX, how to get only a few selected rows? - mdx

I have a Color dimension with many colors, but I want to show a table with just two rows (black and red). I tried this:
SELECT [Color].[black] || [Color].[red] ON ROWS,
{[Measures].defaultMember} ON COLUMNS
from [SalesAnalysis]
The result I was expecting was a table with one column and two rows. One cell for black sales, one cell for red sales. An error comes instead.
What MDX request should I write?
I also tried things called "aggregate" and "filter", but it seems that they are not what I am looking for.

OK, I have found:
SELECT {[Color].[black],[Color].[red]} ON ROWS,
{[Measures].defaultMember} ON COLUMNS
from [SalesAnalysis]

Or try something like this:
SELECT {[Color]} ON ROWS,
{[Measures].defaultMember} ON COLUMNS
FROM [SalesAnalysis]
WHERE {[Color].[black], [Color].[red]}

Related

Summing to columns into a third column in SSRS

I have two columns in.column1, ou.column2. I would like to place a third column next to them that totals the number from both columns. I have tried an expression=sum(Fields!in.coulmn1.value,"new_dataset") +(Fields!in.coulmn2.value,"new_dataset")this does not give me the correct answer. Any help appreciated!
When trying the above expression I get a total that does not equal the total of the two columns.
Your code is summing all records in the dataset. If you just want totals per row, try removing the Sum call. Something like...
= Fields!in.column1.value + Fields!in.column2.value

Postgresql: counting distinct changes within a json column across different records with the same reference ID

Is it possible to do this in postgresql?
Here's an example of what my data looks like:
I want to be able to return the number of times this customer, A1, changed their carb selection (should return 1, since they changed it once) or changed their vegetable selection (answer should be 0)
Is it possible to query for this? Thank you so much!

Changing multiple row colours in Report Builder

I would like to change the row colours in the attached image so all rows match with the value in NAME column.
So I want the related 2 rows in CUST CODE, DEL TO, CUST NAME and then the related 3 rows in ORDER NO to be the same colour.
Then i would like the colours to alternate for the next NAME value and so on.
Is this possible? I know how to alternate row colour when each result is one row only, but unsure how to do it with this kind of result.
So to clarify, for NAME (AHe) all rows to be 'lightgrey', NAME (AHO) all rows to be 'whitesmoke', NAME (JH) all rows to be 'lightgrey' etc...
I've used something similar to the following in the background color expression:
=IIF(RUNNINGVALUE(Fields!Name.Value, COUNTDISTINCT,"MainDataSet") MOD 2 = 0,
"LightGrey",
"WhiteSmoke")
There may be another way to do this using ROWNUMBER() or another alternative as well.

how can I summarize different columns to make totals by row?

how can I summarize different columns to make totals by row?
on the picture below you can see my statement, definitely is something wrong there because is returning NULL value, but I don't know what it is. I want to create a TOTAL column summarizing WOSE, WO, SSSE and SS per row. Could someone help me with that?
It is because of null values in the columns -Use the following instead -
SUM(COALESCE(WOSE,0) +COALESCE(WO,0) + COALESCE(SSSE,0)+COALESCE(SS,0))

How to retrieve a part of a value in a column

Correction - I only need to Pick the WORK value every result set in the column will contain comma seperated values like below..
"SICK 0.08, WORK 0.08" or "SICK 0.08,WORK 0.08"
I only need to pick WORK 0.08 from this.
I am quite new to SQL
I am using the following script to get some results;
select Work.Work_summary, Work.emp_id
from Work
all work fine. but the first column has values like the following :
WORK 08.57, SICK 08.56 (Some columns)
SICK 07.80, WORK 06.80 , OT 02.00 (Some columns)
How can i only retrieve the column with only the WORK% value, if there is no WORK value the results shall be empty.
select Work_summary, emp_id
from Work
where Work_summary like '%WORK%'
This will return the rows in the Work table where Work_summary column contains the word WORK. See the documentation for more details.
Contains is faster than like.
SELECT Work_summary, emp_id FROM Work WHERE CONTAINS(Work_summary, 'WORK');
then use: this will give only the result where work summary contains work content.
select Work.Work_summary, Work.emp_id
from Work where contains(work.Work_summary ,'work');
select replace(Work_summary,",","") as work_summary
from Work
where upper(Work_summary) like '%WORK%'