How can I do a DAX naturalleftouterjoin? - powerbi

I've got two tables in Power BI: GetWordCounts and CountTopN.
GetWordCounts has three columns: Columns, Columns2, and Count.
CountTopN has two columns: GetWordsCount_Count and Count.
I established a many-to-one relationship between the tables, linking the columns CountTopN[GetWordsCount_Count] and GetWordCounts[Count].
(The related columns are both data typed as whole numbers.)
I created a new blank table and added: Table = NATURALLEFTOUTERJOIN(CountTopN,GetWordCounts).
I receive the error: The Column with the name of 'Count' already exists in the 'Table' Table.
I don't understand what I'm doing wrong. I'll appreciate any assistance.

I just found the answer here.
Bottom line is I had columns in each of the two tables named Count and one of them was not part of the join condition. I renamed the one in CountTopN to Count2 and the join worked.

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]
)

Power BI Measures with Conditional Filtering

I have what I believe is a simple problem in Power BI, but I'm having trouble solving it.
I have a model with three tables, tbCalendar, tbFiles and tbCategory.
Both the tbCalendar and tbCategory tables have a relationship with tbFiles. tbCalendar's relationship with tbFiles is a many-to-many relationship in a column they both have called "Date" and between tbCategory and tbFiles is a one-to-many relationship made through a column called "Category".
I want to create a measure that makes a distinct count of a column called "KeyCod" of tbFiles where some values are repeated. But I want this measure to ignore all the filters I created except one, the "Date" column filter of tbCategory table to reuse this result in other solutions in my model.
So far I've tried in a few ways, but I haven't gotten the result I need. Could someone help me with this please?
My current measure is:
CountKeyCodRows =
VAR TotalRows = DISTINCTCOUNT(tbFiles[KeyCod])
RETURN CALCULATE(TotalRows,ALLSELECTED(tbCalendar))
Replace ALLSELECTED with ALLEXCEPT
CountKeyCodRows =
VAR TotalRows = DISTINCTCOUNT(tbFiles[KeyCod])
RETURN CALCULATE(TotalRows,ALLEXCEPT(tbCalendar))

make all values of mutiple columns in one column Power Bi

I want to get this result (in the picture) using this code but it doesn't work , any suggestions to have all the values of all columns in one column and keep occurrences.
AllZipCode=UNION(SUMMARIZE('Table','Table'[ZipCode1]),
SUMMARIZE('Table','Table'[ZipCode2]),
SUMMARIZE('Table','Table'[ZipCode3]))
It is unlikely to combine all the column and return it in the existing table, else it will return error, by create a new table to join all the column referring to the table, you can achieve the expected output:
Table = UNION(SELECTCOLUMNS(Sheet1,"col1",Sheet1[Zip1]),
SELECTCOLUMNS(Sheet1,"col2",Sheet1[Zip2]),
SELECTCOLUMNS(Sheet1,"col3",Sheet1[Zip3]))
Original table :
Union table:

How to make a existing column "unique" in PowerBI, so I can form a "one-to-many" relationsship?

I have 40 tables. One table has 20 rows, and one of the columns have 1385 distinct values.
I would like to use this in a relationship with another table.
TableName(1385 rows) Column:Name:(1385 distinct values)
But when I try to do this in Powerbi/Manage-Relations, it will only accept the option "Many-to-Many" relationship. It reports that none of the column are "Unique".
Well, the data in the column is unique. So how can I configure this column to be unique so I can use it in a "One-to-Many" relationship"?
Do I have to edit the DAX expression and put the "DISTINCT" keyword in the expression for that column? And How?
Now I have:
}, {"Columnname", Int64.Type}, {
what you can try is to perform remove duplicates in that table(i know its already contains distinct values but you can give it a try)... and/or just load the data again.
Best way would be when you group your data in the query editor. This way your table has only distinct values and you can create your relationship.
In the query designer under Home > Group By you can group after your column.
Example
Table:
Table (2):
Relationship (One to Many):
Result:
I hope this helps.

Power BI : How to count occurrence of value from source table?

I have my data source something like below.
I need to show output in the report as below.
I tried using the unpivot column and getting something like this, how to count the occurrence value of each Business value.
Plot following mesure against Value column (from your unpivot table):
Business Occurance = COUNTROWS('your unpivot table')
We have to remove the Attribute column as the next step to Unpivot. Then my table should be looks like this.
Now create a new table with following Dax function, let's say the current table as Business Data (Your Unpivot table)
Occurrence Table = DISTINCT('Business Data')
Now end result table should look like this,
You can make use of this table for your table visual in the report.
Note: You can add n-number of rows and column into your source table and this logic will do magic to get the correct result.
I have marked two places first marked place you have to add Value column then click second marked place one dropdown value is open click count menu