I would like to create a calculated dimension. How it should works is extract data from a column based on different condition, i was looking at the formulation in equivalent to the following:
In SQL:
CASE WHEN REGEXP_MATCH(Data Field A,"((?i).*PMP).*")
THEN "PMP Deal"
WHEN REGEXP_MATCH(Data Field A,"((?i).*Native Display).*")
THEN "PMP Dea"
ELSE "Non Standard Formats" END
In English:
If Data Field A contains text string PMP, please return results in column A as PMP Deal.
If Data Field A contains text string Native Display, pleas return results in column A as Native Display.
Related
I have a collection with job titles and question id's called colFunctions. I want to compare the job titles in the collection to a single known job title (a text value) and return a list of question id's.
So for the function Jr. System Administrator I want to get a list with ID's of Q01 and Q03, but not Q02.
I have this so far, but it says I can't compare a table to a text value. How can I overcome this?
ClearCollect(
colMatchedFunction,
Filter(colFunctions,Function = Office365Users.UserProfileV2(galleryDirectReports.Selected.userPrincipalName).jobTitle).QuestionID
);
If Function is a text column in SharePoint, or a multi-select choice column? If it is a text column, you can use the in operator, which can check if a the text contains the given id:
ClearCollect(
colMatchedFunction,
Filter(
colFunctions,
Office365Users.UserProfileV2(galleryDirectReports.Selected.userPrincipalName).jobTitle).QuestionID in Function
));
In a multi-select choice column, you can still use the in operator, this time to check if a value belongs to a table, checking it against the 'Value' property of the multi-select column (which returns the text value represented by the choice):
ClearCollect(
colMatchedFunction,
Filter(
colFunctions,
Office365Users.UserProfileV2(galleryDirectReports.Selected.UserPrincipalName).jobTitle
in Function.Value
));
My data in Tableau is in pivot format.
Region/City/Neighboor/Street columns, metric column with different numerical metrics and a column "Measure" that stores the given metric's value.
I want to create a calculated field and combine the SUM(Measure) if metric=A with some text
I tried creating a calculated filed as "Some Text" + STR(SUM(IF metric='A' THEN Measure END))
I receive an error "Cannot mix Aggregate and Non Aggregate Arguments" Is there any way to mitigate this issue ?
Thank you
Already the measure is aggerated try using this : "Some text" + str(if ATTR([Region])='Europe' then Measure_value end)
I have a table with a few key columns created with nvarchar(80) => unicode.
I can list the full dataset with SELECT * statement (Table1) and can confirm the values I need to filter are there.
However, I can't get any results from that table if I filter rows by using as input an alphabet char on any column.
Columns in table1 stores values in cyrilic characters.
I know it must have to do with character encoding => what I see in the result list is not what I use as input characters.
Unicode nvarchar type should resolve automatically this character type mismatch.
What do you suggest me to do in order to get results?
Thank you very much.
Paulo
We have a spreadsheet that gets updated monthly, which queries some data from our server.
The query url looks like this:
http://example.com/?2016-01-31
The returned data is in a json format, like below:
{"CID":"1160","date":"2016-01-31","rate":{"USD":1.22}}
We only need the value of 1.22 from the above and I can get that inserted into the worksheet with no problem.
My questions:
1. How to use a cell value [contain the date] to pass the date parameter [2016-01-31] in the query and displays the result in the cell next to it.
2. There's a long list of dates in a column, can this query be filled down automatically per each date?
3. When I load the query result to the worksheet, it always load in pairs. [taking up two cells, one says "Value", the other contains the value which is "1.22" in my case]. Ideally I would only need "1.22", not the title, can this be removed? [Del won't work, will give you a "Column 1" instead, or you have to hide the entire row which will mess up with the layout].
I know this is a lot to ask but I've tried a lot of search and reading in the last few days and I have to say the M language beats me.
Thanks in advance.
Convert your Web.Contents() request into a function:
let
myFunct = ( param as date ) => let
x = Web.Contents(.... & Date.ToText(date) & ....)
in
x
in
myFunct
Reference your data request function from a new query, include any transformations you need (in this case JSON.Document, table expansions, remove extraneous data. Feel free to delete all the extra data here, including columns that just contain the label 'value'.
(assuming your table of domain values already exists) add a custom column like
=Expand(myFunct( [someparameter] ))
edit: got home and got into my bookmarks. Here is a more detailed reference for what you are looking to do: http://datachix.com/2014/05/22/power-query-functions-some-scenarios/
For a table - Add column where you get data and parse JSON
let
tt=#table(
{"date"},{
{"2017-01-01"},
{"2017-01-02"},
{"2017-01-03"}
}),
add_col = Table.AddColumn(tt, "USD", each Json.Document(Web.Contents("http://example.com/?date="&[date]))[rate][USD])
in
add_col
If you need only one value
Json.Document(Web.Contents("http://example.com/?date="&YOUR_DATE_STRING))[rate][USD]
I have predefined item combination (for example brand1|brand2|brand3 etc) in the table.
i like to collect brands and check against with predefined table data.
For example i collected brand1|brand2|brand3 then i can do get some value form that predefined table(it meets the condition).
How can i check?
brands would be unlimited. also brand1|brand2|brand3 of brand1|brand2| exist then returns true.
Okay, taking a wild guess at what you're asking, you have a delimited field with brands in them separated by a | character. You want to return any row that has the right combination of the brands in there, but don't want to return rows with, for example, brand "testify" in them when you search for "test".
You have four search conditions (looking for brand3):
the brand exists by itself: "brand3"
the brand starts the delimited field: "brand3|brand4|brand6"
the brand is in the middle of the field: "brand1|brand3|brand6"
the brand is at the end of the field: "brand1|brand2|brand3"
so, in SQL:
SELECT *
FROM MyTable
WHERE BrandField = 'brand3'
OR BrandField LIKE 'brand3|%'
OR BrandField LIKE '%|brand3|%'
OR BrandField LIKE '%|brand3'
Repeat as required for multiple brands.