How to add a new column with custom values, based on a WHERE clause from another table in PowerBi? - powerbi

I am stuck while dynamically forming a new column based certain WHERE clause from another Table in PowerBi. To give more details, let's say I have a table with item numbers associated with a Customer Name. In another table, I have to add a new column, which will dynamically add the item numbers associated with a particular customer and append as a query parameter to a base url.
So, my first table looks like this:
The second table that I want is this:
The query parameter value in the URL, has to be dynamically based on a SELECT query with a WHERE clause and pick up the ItemNumbers using the Customer field which is common between both. So, how can this be done in PowerBi? Any help would be really appreciated :)

I have one table in my model "TableRol" if I want to summarize my Date as the string I can use CONCATENATEX;
URL = CONCATENATE(CONCATENATE("http:\\mysite.com\parametersHere\getitem?='",CONCATENATEX(VALUES('TableRol'[Date]), 'TableRol'[Date],";")),"'")

Related

Power BI LOOKUPVALUE with a column of values for the search items? (VLOOKUP alternative)

In Power BI, I need to create a VLOOKUP alternative. From the research I've done, this is done with the LOOKUPVALUE function, but the problem is that function needs one specific SEARCH ITEM, which isn't super helpful in a VLOOKUP type scenario where you have a full column of values to search for?
Given these two tables, connected through the user_name and first_name columns:
...what's the formula needed in order to create a new column in the Employee_Table called phone_call_group by using the names as the search items in order to return the group they belong to? So how can I end up with this?
(Forget that the entries in each table are already sorted, needs to be dynamic). Will be back tomorrow to review solutions.
In Power BI you have relations between tables instead of Excel's VLOOKUP function.
In your case you just have to create a one-to-one relation between
'Phone_Call_Table'[user_name] and 'Employee_Table'['first_name]'
With that you can add a Calculated Column to your 'Employee_Table' using the following expression:
phone_call_group = RELATED(Phone_Call_Table[group])
and in the data view the table will look like this:
LOOKUPVALUE() is just a workaround if for other reasons you can't establish that relation. What you've been missing so far is that in a Calculated Column there is a Row Context which gives you exactly one value per row for the <search_value> (this is different from Measures):
alt_phone_call_group =
LOOKUPVALUE(
Phone_Call_Table[group],
Phone_Call_Table[user_name],
Employee_Table[first_name]
)

How to create a field with a list of choices but store the index?

I'm making a Microsoft Access table where one of the fields is a list of pre-made options. When I make a SQL query on that table it returns the values of the list as strings containing the spelled out choice. I would like to assign numerical values to each element of the list so a SQL query returns a number instead. How do I do this? I know it's possible because I have an access file with such a list but I'm unable to recreate it.
An easy way to do this is to have your combo box use a query of the table as a Rowsource. This query would have the table unique ID in the first field and the field you wish to return as the second field. Then change the setting on the combo box for "Column Count" to 2. If you want to show both fields change the "Column Widths" value to 1"; 1". If you want to show only one field, change the value of one you do not want to see to 0. Now we you refer to this list in an SQL queries, it will use the ID field but show the user the string field.

How to add a custom index by specific column value?

I have a table with with 2 columns:id(of a movie) and actor_name. For each id, there can be multiple actor names.
I want to add a new column with an index specific for each actor.
My table look like this:
Id.......actor_name
5........Al pacino
6........Tim Roth
7........Antonio Banderas
8........Al pacino
And I want it to look like this:
Id.......actor_name..............actor_number
5........Al pacino.................. 1
6........Tim Roth....................2
7........Antonio Banderas......3
8........Al pacino...................1
I'm doing this in power BI. I have a table with each actor and a specific index, but I can't make the connection between them because I don't have unique values in the the actor_name column.
Thank you in advance!
I would resolve this in the Query Editor/ Power Query. First I would build a query (lets call it Actor Index) by Reference to your "table with each actor and a specific index". I would either use Remove Rows / Remove Duplicates or Group By to ensure there are unique values for each actor_name.
Then over in your "My Table" query, I would add Merge and Expand steps to join to the new Actor Index and return the Index.

Work with matrix (I can't edit visualisation)

I have this table in Power BI, But I can't do another table.
How I can do this?
Now the values are grouped by date (different fields have information under one date, next the same fields are grouped by another date)
I want the values in the columns to be grouped by field (one field has date information next to it).
Edit1:
I can't set Date on the 2nd place in the grouping
Because date is column, traffic,orders,rev,costs- are values
You need to set Date on the 2nd place in the grouping, after a field containing traffic, orders, etc.
EDIT:
You need to unpivot these columns first, for example, in PowerQuery. Use Edit Query. This results in transforming your 4 columns to 2: Attribute and Value. Attribute will be your first grouping parameter. 2nd will be Date. Value column goes to values.
If you need your source query somewhere else, you may create new query for this very report only. It is done by first right-clicking original one and selecting Reference Query, and the doing any edits. This will keep original query intact.

Dynamodb2 Table Schema Creation

I'm using the following: dynamodb2, boto, python. I have the following code for creating a table:
table = Table.create('mySecondTable',
schema=[HashKey('ID')],
RangeKey('advertiser'),
throughput={'read':5,'write':2},
global_indexes=[GlobalAllIndex('otherDataIndex',parts=[
HashKey('date',data_type=NUMBER),
RangeKey('publisher', date_type=str),
],throughput={'read':5,'write':3})],
connection=conn)
I would like to be able to have the following data that I can query by:
ID, advertiser, date, publisher, size, and color
That means I need a different schema. When I add additional points it does not query unless the column name is listed in the schema.
The problem however is that right now I am only able to query by Id, advertiser, date, and publisher in this case. How can I add additional columns that I can query by?
I read this which appears to say that it is possible:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html
However there is no example here:
http://boto.readthedocs.org/en/latest/dynamodb2_tut.html
I tried adding an additional range key however it doesn't work (cannot have duplicates)
I'd like it to be like:
table = Table.create('mySecondTable',
schema=[
RangeKey('advertiser'),
otherKey('date')
fourthKey('publisher') ... etc
throughput={'read':5,'write':2},
connection=conn)
Thanks!
If you want to add additional range keys you need to use Local secondary index.
You can query the LSI in the same way that you query the base table. You need to provide an exact value for the hashkey and a comparison-predicate for range key.