Find Number of times a particular character appears in a string using MDX query - ssas

In the Microsoft SSAS, I have a dimension column that contains multiple values separated by the special character | in a single row as below.
Example value of a row: Image|Video|Audio|
Requirement:
So, I need to count the number of values present in the dimension column using the special character.
In this case, I need to get the count of | using the MDX query and my expected answer is 3.
Could someone help me with this? In short, Is there an MDX function that counts the number of times a particular character appears in a string?
Similar question for SQL: Number of times a particular character appears in a string

Related

Select entries with substring in a specific position of the word

I am trying to write an SQL query where my goal is to select all the entries that contains a substring in a specific position of a word (the entries are phrases with multiple words).
To make it clearer, suppose that I have these two entries (values inside a column, call it phrase):
1 - "Jamming in New York"
2 - "bosbessenjam 30g"
3 - "30g bosbessenjam"
4 - "Tranches de jambon fumé"
I want to select all the rows that contains a word that ends with "jam". So I want the second and third row.
I tried using LIKE '%jam%', however it just check the overall string and not the single word. So LIKE '%jam' returns the third row, but not the second.
Any idea on how to do this?

SSRS insert exact specific value in a cell of a Matrix using expression

I'm not sure if my question is really stupid, but I found nothing on the internet...
Is it possible to insert a specific value in a cell of a matrix?
for example I have a dataset like below:
Month Prod Amount
2 X 34$
11 Y 12$
7 Z 150$
and a matrix like:
-------| Month |
Prduct |SUM(Amount)|
So the row group are products and column group are the months of a specific year.
If I want to add an extra column, with a specific value chosen dynamically from the amount (for xample 150$) so to have
-------| Month |columnName
Prduct |SUM(Amount)| 150
is that possible? also if the value is repeated through the column (it would be useful if I wanted the new column to have this specific value added for each value)
thanks a lot!! :D
You can insert a value directly in your matrix but it will be repeated for each record.
The best way is to add a new column with conditional values is to do this in your dataset query. Probably with a CASE statement if you are using SQL.
EDIT: If you can't adjust the query for whatever reason, you can add the new column and use SWITCH function inside your textbox to achieve the same.

SQLite3 Order by highest/lowest numerical value

I am trying to do a query in SQLite3 to order a column by numerical value. Instead of getting the rows ordered by the numerical value of the column, the rows are ordered alphabetically by the first digit's numerical value.
For example in the query below 110 appears before 2 because the first digit (1) is less than two. However the entire number 110 is greater than 2 and I need that to appear after 2.
sqlite> SELECT digit,text FROM test ORDER BY digit;
1|one
110|One Hundred Ten
2|TWO
3|Three
sqlite>
Is there a way to make 110 appear after 2?
It seems like digit is a stored as a string, not as a number. You need to convert it to a number to get the proper ordering. A simple approach uses:
SELECT digit, text
FROM test
ORDER BY digit + 0

What does splunk count when more than one field is used in the 'top' command?

When I type this search query in splunk search head:
index=main sourcetype=mySrcType | top fieldA fieldB
Splunk automatically adds count column to the resulting table. Now, what is this count? is it a simple sum of each field count?
The count is showing you the number of times thatt field value pair show up in the time range and query you ran. If you want to exclude it, you can add
| fields - count
Top counts the most common 10 values of each of the fields you list after it's command
You can read more about it on its documentation page
http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Top

Check for 6 or more consecutive numbers in a column in oracle sql

I need help with a query to identify unstructured data. I need to identify all the rows which have more than 6 consecutive numbers in their data. I know we can use regular expressions like ^[0-9] for the same.
For example:
I have a column named Address. The address column may contain 6 or more consecutive numbers. I need to identify which rows contain more than 6 consecutive numbersi in them.
675467 should be the output
67433232 should be the output
4453 should not be the output.
I second Egor Skriptunoff, you can the answer on this demo on SQLFiddle