I'm using Teiid 9.3.7 with Wildfly 10 due to Teiid Designer version compatibility. I'm trying to build a view out of a flat file. There are two different types of entries in the file. Each type of entry has a key attribute that I need in order to join with other tables, but the position of the key attribute are different for each type of entries. The first number(4) will tell me which kind of entry is that row. I imported the data source and parse each row the same way, so I can catch the key attribute from both types of entries but as different columns. The transformation of the view looks like this
SELECT
A.TYPE, A.column_1, A.ID, A.column_2, A.KEY_ATTRIB_1, A.column_3, A.KEY_ATTRIB_2, A.column_4
FROM
(EXEC CorrSourceModel.getTextFiles('my_input.txt')) AS f, TEXTTABLE(f.file COLUMNS TYPE string WIDTH 4, column_1 string WIDTH 32, ID string WIDTH 9, column_2 string WIDTH 2466, KEY_ATTRIB_1 string WIDTH 25, column_3 string WIDTH 1445, KEY_ATTRIB_2 string WIDTH 13, column_4 string WIDTH 2854) AS A
So in the view, I can see both key attributes in their column fine. The final virtual view schema I need to build is the original line of the row, the key attribute of that row, and additional attributes I join from another data source with that key attribute. So in order to do that, I need to test the first attribute (4-digit number) so I know witch column is my key attribute for the row. It's like I need a IF... ELSE statement.
If there a way to accomplish that? Thanks.
See SELECTOR in this document [1] that should let you pick the lines. You can have two TEXTTABLE constructs one for each SELECTOR type and then join them if needed to get a combined result.
[1] http://teiid.github.io/teiid-documents/master/content/reference/r_texttable.html
Related
I have a query:
Select * from my table
That gives me 20 fields.
There is 3 columns that all begin with index in column name that I want to hide.
I could explicit all fields in query, but for 17 fields, it might not be the best solution.
In Options,
I use this regex, /index(.*)/
When I change the column header, I can see the header of the 3 columns is changing which means my regex is OK.
But when I change the type from String to Hidden, all my column except time disappear.
Is there something I am missing ?
I have imported a JSON file into PowerBI and it contains a column in which the values are of type "List". I am looking to expand that column into multiple columns.
Specifically, the data contains a Sprint Name, the start date and the end date of the sprint, along with some other values associated with each sprint.
Trying to use "Expand to new rows" duplicates each sprint instance, creating a table that looks like this, duplicating each sprint instance multiple times for each associated value:
Sprint Name Value
JAN(S1Dev) 2019-01-01
JAN(S1Dev) 2019-01-13
JAN(S1Dev) {attribute}
JAN(S1Dev) {attribute}
JAN(S2Dev) 2019-01-14
JAN(S2Dev) 2019-01-31
JAN(S2Dev) {attribute}
JAN(S2Dev) {attribute}
FEB(S1Test) 2019-02-01
FEB(S1Test) 2019-02-15
... ...
I would like to do something similar to the "expand" feature, which instead creates a new column with each attribute rather than a new row. This is currently vastly increasing the size of my table for no reason, while also making the data practically un-useable. Any help would be appreciated, cheers!
I have found a very simple solution to this, but as it took me some time to figure it out I will answer my own question instead of deleting it to help others in the future...
Upon importing the JSON data into PowerBI first select "Convert to Table" to view the data as a table with editable properties.
Next, click the arrows pointing away from each other at the top of the column of Lists, and select "Extract Values".
Select a delimiter to use for concatenating values, I am choosing a comma since I know that the data contained within the list does not have any commas in it. If your data contains commas within it, choose something else. Similarly, if your data contains one of the delimiters, do not choose that as the delimiter.
It should now display a comma-separated list where it previously displayed "List" in orange text.
Now, right-click on the column and select "Split Column" then choose "By Delimiter"
Select the delimiter that you previously chose, and under "split at" select "Each occurrence of the delimiter" then click OK.
Your column should now be split into multiple columns based on the list!
I'm trying to use the CASE statement to output string values for an Event Label field using RegEx to produce a table that shows the number of events for each field value. So, if I'm looking for foobar, and other string values separately, within values for Event Label; it may either stand alone or be part of a URL like so:
|[object HTMLLabelElement] | Foobar |
/images/foobar-26.svg
It seems REGEXP_EXTRACT might suit this the best:
CASE WHEN REGEXP_EXTRACT(Event Label, '.(?i)foobar.') THEN Foobar
However, the table produced using the calculated field as the dimension only contains a blank row that seems to be the sum of the number of events.
What am I missing?
I think you need to use REGEXP_MATCH not REGEXP_EXTRACT, given your existing syntax, or to change the syntax to a straight REGEXP_EXTRACT without the CASE element.
In Power BI Desktop, I'm trying to order the following column with repeated values by an ID column (contains primary key).
This returns the error: "There can't be more than one value in "Nível2"...."
In this other post it seems the suggestion is to concatenate the values of the column so they don't get duplicate.
But I want them to be repeated so they can aggregate values in visuals.
So, what's the workaround for this situation?
Thanks in advance for helping!
The issue is that your sort column (i.e. your ID column) contains multiple values for each value in the column you are trying to sort (i.e. your Nivel2 column).
You need to ensure that your sort column contains only one distinct value for each value in the column you are trying to sort.
One way to achieve this would be to create a new (calculated) sort column based on your ID column. It could be defined like this:
SortColumn:=CALCULATE(MAX('YourTable'[ID]),ALLEXCEPT('YourTable','YourTable'[Nivel2]))
Here is an example of how the SortColumn would behave:
Id Nivel2 SortColumn
1 Caixa 4
2 Caixa 4
3 Caixa 4
4 Caixa 4
5 Depósitos à ordem 7
6 Depósitos à ordem 7
7 Depósitos à ordem 7
You can now sort Nivel2 by SortColumn.
EDIT - The implementation of the SortColumn should be done in the data source
There seems to be a limitation in PowerBI where it checks the implementation of the sort column rather than the data in the sort column. Therefore the above solution does not work, even though the data in the sort column is perfectly valid. The above solution will throw this error when you attempt to sort [Nivel2] by SortColumn:
This column can't be sorted by a column that is already sorted, directly or indirectly, by this column.
The implementation of the SortColumn should be moved to the data source instead. I.e. if your data source is an Excel sheet, then the SortColumn should be created inside the Excel sheet.
The above answer does explain the issue and the resolvation correctly. The only change is that the SortColumn must be implemented outside of the tabular model (PowerBI) to ensure that PowerBI does not know about the dependency between the SortColumn and the [Nivel2] column.
In my case, I calculate the levels from a parent-child hierarchy
Path = Path([id],[father])
For each level:
Level1 = LOOKUPVALUE([Name],[id], PathItem([Path],1))
Level2 = LOOKUPVALUE([Name],[id], PathItem([Path],2))
.....
Then I created a new column for each level to sort the column Level:
SortL1 = LOOKUPVALUE([nID],[id], PathItem([Path],1))
SortL2 = LOOKUPVALUE([nID],[id], PathItem([Path],2))
.....
id and nID is the same numeric variable but "id" in string format because Path do not support numeric values.
Specifically in sitecore, the column configuration is defined using a Name Lookup Value List, and I want to add a colour drop down along side it so it can be applied specifically to each column as set up by the configuration. This means for each key (column ID) I want the column config as a drop down and the colour as a drop down.
If you don't want to create a custom field that will allow to do this, you should:
Create Column Specification template
Add 2 fields to this template: Column and Colour
Create items using this new template for every column you need
Instead of selecting columns in your Name Lookup Value List, select Column Specification items.