I work on Power BI and I want to create a Slicer (Filter) to multiple tables that have a common key (like in excel that I can choose a slicer and the pivot tables that it will affect on).
Is there any way to do so or do I have to I merge the tables I want to work on?
You need to create a relationship between the tables: Home tab -> Manage Relationships -> New / Autodetect.
Make sure to set Cross Filter Direction to both.
There is no many-many relationship model, so if the column has duplicate values in both tables, you will need to introduce a third table with unique values to join on.
Related
I am setting up a system to manage the lifecycle of operating system images as they relate to certain products. I am using Laravel/Eloquent and I am currently trying to set it up using a pivot table.
I have set up a pivot table (image_os_product_statuses) with 4 foreign keys (product_id,os_id,image_id, and status_id). Below is a list of the tables I am using.
os products images statuses image_os_product_statuses
My goal is to keep track of the status for any given product, os, image combination in this image_os_product_statuses table. Eventually, I would like to be able to query a specific image for a given product/os combination.
I am struggling to figure out how to set this relationship up with a pivot table. Is this 4-way relationship too complicated to set up with a pivot table in Laravel or is there another method I should be trying?
I have two fact tables: FactSales & FactInvoices. Both have an foreign key relationship with DimDate.Datekey. In VS, the SSAS DSV displays these relationships (the lines are drawn between the tables).
In the DSV I decided to to create a named query that limits the dimdate to 2021. After doing this, I still see the relationships between the two fact tables and dimdate (which is now a named query).
At the DB-level, I created a 3rd fact table called FactExpenses. FactExpenses also has an FK relationship with DimDate.Datekey. The problem is that my dsv (in SSAS) does not recognize this relationship (ie. It doesn't draw the line between both tables).
Two questions: why doesn't VS display the relationship between my 3rd fact table with the named query but it does with the other two fact tables? I understand that the relationship isn't with the named query, but the relationship should disappear in all the fact tables.
When I want to limit the amount of data displayed in dimdate, should I use a named query?
The relationships in the DSV are separate to the foreign keys on the base tables, but they get added automatically based on the database schema when you add tables to the DSV. My guess would be when you added the initial dim and fact tables to the DSV in Visual Studio it automatically added the relationships based on the foreign keys that exist on the base tables, but this may not occur automatically for named queries. You can manually add the relationship yourself for the third table to get the same result.
I think a named query is a reasonable approach for the filtering you want to do. An alternative would be to create a view in the source database if you need to do more intense or complex filtering.
Context:
I am creating a dashboard in Excel based on the data model I am building in Power Pivot. The source data in the data model is based on various other excel tables I am regularly receiving and copy-pasting into my workbook (their incoming structure is out of my control). My goal is to perform all data processing within Power Pivot/DAX rather than manipulating the data in the worksheets before loading into the model.
Problem:
In my model, I have a table (tabCases) which includes status updates on all cases from a management system. This table has a column named case-ID (not unique). I need to create a lookup-table with unique case-id's where I can create new columns with various KPIs for each case.
How can I do this in Power Pivot?
I found two suggestions in this article but none of them work for me (opt. 1 because it requires a manual creation of the unique ID list and opt. 2 because I don't have a database access).
In my mind there should be something really simple I could do, such as i.e.:
Add new table to data model
Set first column to be equal to DISTINCT(tabCases[caseID])
Is there such a way?
A Linkback Table might help you. Please see the link below:
https://www.sqlbi.com/articles/linkback-tables-in-powerpivot-for-excel-2013/
Thanks
I have encounter a problem that I am not able to solve :/
So, I currently have 4 Models: Make > Model > Generation > Version(['engine_type'])
I need to get a unique list of all the fuels (engine_type) that a certain car model has within it's versions. i.e: for $model = Model::find(1) I want all of it's $model->generations()->versions()->get('engine_type') as a list of unique ids so I can know which engine types this car models has!
Thanks in advance!
first step: you should get all generations for the current model, that would be achieved by join table 'models' with table 'generations' ....
second step: join the results with the table 'versions' witch contain the result column we desire to show ('engine_type')
this chain of join should use the foreign keys that represent relations between the tables, so you have to make sure that you setup up your relation well ...
third step: after selecting 'versions.engine_type' use 'distinct()' to make sure there is no duplicate result,
more about distinct in:
https://laravel.com/docs/7.x/queries#selects
$ids= Model::where('id',$modelId)->join('generations','generations.model_id','models.id')
->join('versions','versions.generation_id','generations.id')
->select('versions.engine_type')->distinct()->get();
I am using Database First EF to generate model from the existing database. When I first generated the models, it ignores only one of the table, the entity was not added to EDMX, no model file is created for the table and no context is created for the entity.
When I tried to explicitly add the table to EDMX (when generating the model, selected the specific table first and then updated the model with all the other tables from the database), it complained with the following error.
Two entities with possibly different keys are mapped to the same row. Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns.
This specific table has two columns which are primary keys of some other tables and both the columns are specified as Primary keys for the table.
Am I doing something wrong or should I handle this table differently since it has two columns defined as Primary Keys? Any suggestions greatly appreciated!
You are not doing anything wrong. Your table is junction table for many-to-many relation. You don't need that table in the model because EF (in contrast to database) can handle many-to-many relation directly without any intermediate. The table is actually mapped on behind of the many-to-many relation - you will see that in mapping details window.
Btw. you are not using code first. Code first = no EDMX.