Relationships break when adding column using query - powerbi

I have a dataset with multiple tables and relationships between those tables which were auto detected when I connected to my PostgreSQL server.
But when I add a column using query, those relationships are no longer effective in the report view and all my graphs show 'blank' labels.
One thing I noticed is that in the Data view, the uuid which are used to make the relationships (my foreign keys in PSQL) appear with brackets and those brackets desappear after I add columns in query.
Before:
After:
I don't know if this helps.
I have tried adding columns with custom queries or simply duplicating an existing column.
I don't have any issue when adding columns using DAX.
Thanks,

Change the type of the column by yourself as one of the first steps in the query editor. You can either go with the brackets or without. Make sure its the same for every other key-/foreign key.
If you lost your relationship you can edit it by yourself. After your ID´s are proparly formatted go to Model (the last on the left pane) and drag and drop your relationship form one table to the other. This way it should work again.

Related

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.

Is there a way that POWERBI does not agregate all numeric data?

so, I got 3 xlsx full of data already treated, so I pretty much just got to display the data using the graphs. The problem seems to be, that Powerbi aggregates all numeric data (using: count, sum, etc.) In their community they suggest to create new measures, the thing is, in that case I HAVE TO CREATE A LOT OF MEASURES...Also, I tried to convert the data to text and even so, Powerbi counts it!!!
any help, pls?
There are several ways to tackle this:
When you pull a field into the field well for a visualisation, you can click the drop down in the field well and select "Don't summarize"
in the data model, select the column and on the ribbon select "don't summarize" as the summarization option in the Properties group.
The screenshot shows the field well option on the left and the data model options on the right, one for a numeric and one for a text field.
And, yes, you never want to use the implicit measures, i.e. the automatic calculations that Power BI creates. If you want to keep on top of what is being calculated, create your own measures, and yes, there will be many.
Edit: If by "aggregating" you are referring to the fact that text values will be grouped in a table (you don't see any duplicates), then you need to add a column with unique values to the table so all the duplicates of the text values show up. This can be done in the data source by adding an Index column, then using that Index column in the table and setting it to a very narrow with to make it invisible.

Power BI Visualize Many to Many

I currently have two tables: A "Send ID" table and an "Affiliation Table" each based on a column of customer IDs.
No columns have purely distinct values so I cannot create a many to one relationship.
I would like to visualize the Send IDs based on the Affiliations as shown here:
Desired Output
I can work with either having the Send IDs repeat per affiliation in the new desired table or have them unique per affiliation - either way works with me.
Any help would be appreciated.
Thank you
noyraz's solution in establishing a many to many relationship based on the customerID should suit your needs.
If you are required to find out where a customer appears in the affiliation table or sendID table, I highly recommend performing a full outer join in the query editor.
Using the picture below, right click on any of the tables, and select reference.
Reference Screenshot
Then rename the table if you like
Click on Merge Queries
In the drop down, select the other table you didnt reference, then click on both customerIDs
select full other join.
Full Outer Join labled screenshot
Expand the new table column
deselect the ID if you like.
Expanding Column Screenshot
If there are occurrences where they don't appear (useful for sending and delivered tables), you can do visual level filters to see where either the Affiliation or SendID is null/blank.
when you create Many To Many relationships like Here
all you have to do next it's just visual this like you desire
hope I understand your question right

Select Columns from multiple tables - Django

I am trying to select all the columns from one table and only a single column from the second table using the Django ORM.The two tables are related by a foreign key but the column in the second table which i want, is not related, so using select_related doesn't work.
I used
FirstTable.objects.filter().values("All first table columns separated by a comma","second tablename__column name")
and this worked fine. Since, the columns are very large in number, i do not want to list all of them in "values". So, i am looking for an easy way to do this.
Thanks for your help
EDIT:
Thanks for the help! I was able to get it working by using annotate like the following.
FirstTable.objects.filter().annotate(variable_name=F("SecondtableFieldName"))
You Can use the extra method in this.
FirstTable.objects.filter().extra("write down here what every yo want")

Get "not allowed for columns on the one side of a many-to-one relationship" errors

i have created Power bi project, It is working fine in the beginning but when i refresh my datasource , i get this error " not allowed for columns on the one side of a many-to-one relationship" . Any can help me ??
I resolved this issue by going into the relationship, right clicking to view properties,
and making it a Many to One Relationship.
Power BI sometimes automatically creates relationships between the queries that are being used to drive the data in the reports. When I have encountered this error or errors like it in the past I:
Go into Manage Relationships
Verify that there is a relationship listed
Evaluate the From and To relationships that are listed as active
Delete any invalid From and To relationships between separate data sets
My most common issue in the past has been that I will have two very different queries pulling data from separate sources with similar column names and Power BI will generate a relationship between them that is invalid. After removing the relationship it has always resolved my issue.
In my case issue was related to the fact that Power BI was threating "SQL View" as a "Table" and as a result it was creating relations for it.
Although I've checked the "Manage Relationships":
and removed one relation which was not reasonable the issue was still persisting.
Then issue solved when I had looked in the "Relations"
tab and found unreasonable relations related to my View and removed them.
None of these answers helped me. For me I received this error when trying to refresh my dataset which had previously worked for some time. After investigating I found the schema of the source database had changed. Two fields that previously didn't allow nulls now allowed nulls and had null values for some rows. My Power BI model still expected these fields not to contain nulls but was throwing this same and very misleading error:
Data source error: Column 'x' in Table 'y' contains blank values and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table. Table: y.
Initially on seeing this error and opening up my report in PowerBI Desktop and going to Modeling > Manage relationships. I looked for a relationship on table y for column x, but no such relationship existed!? Was I confused? You bet.
After investigating further I discovered the database schema change and resolved by updating my Power BI model by going to the data model editor, expanding table y in the Fields panel on the right hand side, selected field x, expanded "Advanced" in the Properties panel and changed "Is nullable" from No to Yes. I then applied the changes, saved the report and refreshed the dataset.
I followed these steps
Step 1: Go to the Model section from the left side of the Power BI Desktop
Step 2: Delete all the relationships (or connections) amongst the tables that have been created by Power BI itself while you were working with the Power Query Editor
Step 3: Click 'Refresh visual and data' option in Home (besides the Transform Data button)
It worked and loaded the new data and also applied the automations done in the query editor.
I got this error on a completely new table made in Power Query, weird since I had no chance to create a relation yet.
Easy fix: Apply a filter that removes all blanks on that column - apply the filter, and then delete this new filter again
Another problem you might have is that "Autodetect new relationships" is turned on:
This is a setting that disables auto-detecting relations under "File/Options & settings/Options/Current File/Data Load/Relationship/Autodetect new relationships after data is loaded"
I had the same issue, after spending hours of searching for a fix and not finding anything, I started scratching around and found the problem took 1second to fix. My issue specifically, was a an additional relationship created within the model. The connection showed up as a "dotted" line one of my tables. I deleted the relationship, refreshed. Done.
This happens when your table or connected tables in excel, contain blank row, for resolving this issue you will need to click anywhere in the excel table, then click on the table tools, then resize table and Select the entire range of cells to include all rows, make sure no blank rows are included then save and get back to your PowerBI then again refresh it, all will work.