Power BI Can't create relationship between two tables - powerbi

I have tables like this diagram, and existing relationships are in highlighted boxes.
Then I tried to create relationship between Dates[Date] and Users[Last Hire Date], I got an error message saying there is an ambiguous conflict.
I don't see what conflict there is and how to overcome it?

The ambiguity is easier to see when you start with the Dates table. The arrows in the relations represent the filter direction. By selecting a certein Date in Dates, you are selecting several Emails in Time Log Aggregation where Date of Worklog equals Date. Simultaneously you are selecting several other Emails in Useres and Groups, where Last Hire Date equals Date. These 2 selections of Emails have nothing in common and they would match only by pure coincidence.
A workaround for this situation would be to duplicate the Dates table.

Related

Filter one sided table in many to one relationship

I would like two measures that SUM the Sales[Value] for all the Sales[ID] that have a specific StatusID in SalesStatus.
One that can filter on Sales[Date], and one that can filter on SalesStatus[statusDate]
Diagram
Regards,
Anders
In this scenario I would consider modifying your model to have only two tables by combining what appears to be two FACT tables (sales, sales status). Depending on what your data consists of I would either UNION the two tables after joining and then treat the date in your Sales table as another status date (i.e. shipped complete or sale finished, whatever that date represents) OR I would join the two tables and have two relationships to the date table.
This will create a duplicated data issue as you will ideally result in having the value column in your final fact table. If you go with the union option, you can force the user to select a single sales status effectively removing the sales duplication. If you end up with two connections to the date table, you can use the USERELATIONSHIP() function to write the two different sales measures, and the one that uses the date from the Sales table will need some clever tricks to ensure the data does measure does not duplicate. I would try to UNION the tables though.
For more details, I would research what's referred to as SEMI-ADDITIVE fact tables in datawarehousing. There is a great article from SQL BI on the subject. I have tried setting up models like you diagrammed and even if I could get them to work through intense DAX measures, they would produce unexpected results and have poor performance. I find the Semi additive fact table pattern to be a much cleaner solution once you get passed the data duplication that results.
Example:

Showing Side by Side Measures from Semi-Related Tables in Power BI

I have a data model in Power BI that, among other things, has the following tables
Employees (Dimension; employee ID/name)
Jobs (Dimension; contains details about the job, including job ID)
Employee history- Contains a record for each day an associate was in a job(snapshot table);
Job Budget History- Contains a record for each day a job was budgeted(snapshot table)
Calendar Table
The table is modeled like so (simplified version):
In Power BI, I am trying to make a simplified table view that contains measures based on both the budget history as well as the employee history for the most recent day in the dataset (simple count rows/distinct count of calendar table)
However, attempting to do so gives me the results below if I try to put both measures on the table. Basically it appears to be doing a cross join between each table and matching associates with jobs they don't have (this happens when the budget is added).
Of course, if I just do one of the singular measures everything works perfectly. I am fairly certain it is because there is no real connection between the 'employee' and the 'budget history' in this relationship, so it is just joining everything on the date without any context.
I have tried several things such as making inactive relationships with userelationship(), using visual level filters etc. but I'm not sure what the best option in this situation would be. (I am trying to avoid bidirectional relationships if possible)
Ideally this information should show on this date that Joe was present as President, Sally was present as an operator, and the Manager position had nobody, but all three were budgeted.
Any advice is appreciated. I have attached a simplified mockup pbix file for reference.
PBIX File
This is a complicated problem for many reasons. I was able to produce this report:
by removing field "Name" from the table and replacing it a measure:
Employee Name =
CALCULATE(
SELECTEDVALUE(Employees[Name]),
CROSSFILTER(Employees[Employee_ID], Employee_History[Employee_ID], BOTH)
)
It looks exactly like the report you want, but if you have additional requirements, you'll need to make sure that such approach works for you.
If this is acceptable, a brief explanation:
the root cause of the issue is missing Employee-Budget relationship. When you put Name in the table as a filter, it doesn't propagate to the budget table and causes a cartesian product.
Removing Name from the table eliminates the need for the filter propagation, but then you won't see employee names. I solved this by pulling employee names with the measure, where required propagation is forced by CROSSFILTER function (essentially, it's like a temporary bi-directional relation only when you need it, so it does not negatively affect the rest of the model).

PowerBi seems to lose state of connection depending on the field I pick

I have a model with multiple tables. Four tables:
Two tables:
FactLocation
DimLocation
Are connected on:
LocationKey
And two more tables:
FactPurchaseOrder
DimPurchaseOrder
Are connected on:
PoKey
In addition:
DimLocation
FactPurchaseOrder
Are also connected on:
LocationKey
I have a table view, that I would like to use columns from all tables for.
I started out adding items from
FactLocation
dimLocation
everything was going fine. Then I added one column from
FactPurchaseOrder[OrderQuantity]
And that went fine. Then I tried to add:
FactPurchaseOrder[OrderDate]
Initially, I see that it recognized the date format, and it shows me, under Values, the OrderDate and underneath it Year, Quarter, Month, Day fields, but I also get the following error message, inside the Table visual:
Can't display the visual
Relationship Detection
There is a missing relationship between these fields. Use autodetect to search for relationship, or create them manually.
If I click on autodetect, it tells me No relationships were detected.
The same happens to the other columns from that table.
Any idea what I should be looking for? there is a relationship between the tables, and at least one field was allowed.

PowerBI / PowerQuery: Date slicer for multiple tables

Fellow PowerBI enthusiasts,
I am working on a reporting tool for our support team within our company. They would like to see the hours worked for each operator on a specific selection of dates. This could be just one day, or the whole week.
There are three different kinds of tasks that can be logged. Either time spent on Changes, on Incidents or on Operations (Change-, Incident- and OperationsActivityTimeRegistrations). There is a relationship between these registration tables and the operators table to show the full names in the PowerBI Dashboard, but there is one problem:
I cannot make a proper slicer for the dates. If I select one of the dates from a ___TimeRegistrations table, it will only filter on the dates for that table. That's why we made a new table called 'Datum' which contains all the dates from 1-1-2018 till 31-12-2019 and use those as input for my slicer, but I cannot make a link.
A picture of the relationships: https://imgur.com/a/eoB3rvE
A picture of the report: https://imgur.com/a/yhrACoV
Thanks in advance!
Kind Regards,
Sander

Creating Date Relationship in Power BI for Slicers

I'd like to slice across visuals based on dates in MS Power BI (i.e., one filter for say month will slice all visuals for that time period.
I created a date table from http://www.agilebi.com.au/power-bi-date-dimension/ to link to the date columns in each table.
I connected xlsx workbook.
Image of columns in Power BI
I added tried to edit the relationship so connect the 2 date columns. However, when I insert the filter using the date_table as values and try to use it, the visuals disappear.
Visuals are Gone
However, when I create the slicer and slice across multiple visuals, they go blank.
**I tried changing the type to "Both" but it didn't fix the problem.
The script at AgileBI.com.au creates a date table with a 'Date' field that has a data type of text. You can (surprisingly) do a relationship between 2 fields of different data types and not get an error. However, a join between a text field that contains dates, and a regular date field will mean that rows that look like they should match up do not.
You can confirm this is happening by picking a value in the 2 tables that you think should match up and seeing if they are identical. In my case, I had Tuesday, November 01, 2016 in my imported table, and 11/1/2016 in the other table. While they both represent the same date (in the US), they clearly look different. A good place to see this is in the Edit Relationship screen (and it definitely would have been helpful to include a screenshot of that in your original post).
Anyway, if the dates in your table don't match up to the corresponding (text) dates in the Date table, then when you filter to "2016" on your slicer, the visuals will all go blank.
I would recommend:
Click Edit Queries
On the left hand side, select the table of dates (called Invoked Function by the script)
Click on the header for the Date column (it will likely already be selected)
Select Transform on the ribbon
Change the Data Type from Any to Date
Click Home > Close & Apply
Hope this helps.