Create Calculated Measure based on dimension filter condtion - ssrs-2008

I am trying to create a new calculated measure in my cube based on a dimension attribute value. Fact and Dimension table looks like below.
So, far below MDX script is generated from the form view.
SELECT NON EMPTY { [Measures].[FactCount] } ON COLUMNS
,NON EMPTY { ([DimDate].[Year].[Year].ALLMEMBERS * [DimDate].[Month Name].[Month Name].ALLMEMBERS
*
({FILTER(
[DimFilter].[Desc].[Desc],
[DimFilter].[Desc].CurrentMember.Name = 'F1')
})
) } ON ROWS
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM [FactTest]
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
However above script only returns for the dim filter value 'F1'
How can I get the other measure columns(output table from image) from the cube.
Any kind of help suggestion is appreciated and thanks in advance for your help!

You meant the following query?
SELECT NON EMPTY { [Measures].[FactCount] } ON COLUMNS
,NON EMPTY { ([DimDate].[Year].[Year].ALLMEMBERS * [DimDate].[Month Name].[Month Name].ALLMEMBERS
*
{[DimFilter].[Desc].[F1],[DimFilter].[Desc].[F2]}
) } ON ROWS
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM [FactTest]
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Related

Parameterizing a query with a varying amount of WHERE clause conditionals

Let's imagine we have a table containing columns for 'color' and for 'size'. I have a list with color-size combinations (e.g. [(red, small), (blue, medium)]), of which the length is unknown. The table should be filtered based on this list, so that the result contains only the rows where the combinations apply.
A query based on the example would look like this:
SELECT * FROM items WHERE ((color = 'red' AND size = 'small') OR (color = 'blue' and size = 'medium'));
Parameterizing this query wouldn't work of course, since the amount of combinations varies.
Is there a way to achieve this using the parameterized queries like the ones that are use in node-postgres? The only solution I can think of is using string interpolation, which doesn't appear to be a safe.
It looks like good scenario for IN operator
select * from items where
(color, size) in (('red','small'), ('blue','medium'))
and it can be parametrized using arrays
select * from items where
(color, size) in (
select unnest (array['red','blue']), unnest(array['small','medium']))
First array is for colors, second for sizes. Unnest in one select create pairs.Arrays should have the same number of elements.
And arrays can be passed as parameters to query.

Multiply a constant to each array element

I have a column of TYPE integer[] in PostgreSQL. I want to multiply 1000 to each row and each element of the column in that table. Each row has varying length of arrays.
You could use:
UPDATE tab
SET col = array(select 1000 * unnest(col));
DBFiddle Demo

How to assign the same value to all table cells in a column in a table in Matlab?

I tried
myTable.MyField{:}='AAA'
myTable.MyField(:)='AAA'
myTable.MyField{:}={'AAA'}
myTable.MyField{:}=deal('AAA')
but all failed.
Is there any way?
MATLAB requires:
To assign to or create a variable in a table, the number of rows must match the height of the table.
So it would be:
myTable.MyField = repmat('AAA', length(myTable.MyField), 1);
or if you know the column number of MyField, you can do:
myTable(:,colnum) = {'AAA'}; %where colnum is the column number
or otherwise if you don't know the column number, you can directly use the column name as well:
myTable(:,'MyField') = {'AAA'};

how to retrieve a column's values in order to update a column total

I have a pinned row that acts as a column's total, which works fine using gridOptions.pinnedBottomRowData. I need to update this value when the columns' cells' values change but I cannot find a means of accessing the column values to do so. What's the best means of updating a column total when it's columns' cells' values change?
You can calculate the total on cell value changed or value setter function.
this.gridOptions.onCellValueChanged = function (event) {
if (event.colDef.colId == "ColumnName") {
//Logic to update the total row value
total = total + event.data[event.colDef.field]
}
}

Postgres select rows where ANY in a given array = ANY in column array

In Postgres, I need to select all rows where any value in an array (passed as variable) is equal to any value in the column (that is also an array). This means something like this:
SELECT *
from table
where ANY (value_in_an_array_variable) = ANY (value_in_a_column_array);
If there is no direct way what's the best alternative?
You are looking for the overlaps ("have elements in common") operator:
select *
from some_table
where array_column && array[1,2,3];