i need some help i need a table that contains the name of the CompanyUser and amount of reservations each CompanyUser user has. but the problem is that i can't join 4 tables each table is connected with a different key.
in sql i can do it but in power bi i tried NATURALLEFTOUTERJOIN and NATURALRIGHTINNERJOIN but the problem is that when you did a join and want to join an other table to the created table from before it says can't find an connection.
can somebody help me out.
here is the table
enter image description here
this is the example result
enter image description here
Related
I was working on a data set and had few queries on how to model the data.
I have two FACT tables with the following fields
Budget table
Team Category
Team name
Service line
ID
ID_name
Employee Name
Rank
Location
Employee category
Week ending date
Hours
Revenue
Cost
Revenue or hours category
Actuals table**
Team Category
Team
Service line
ID
ID_name
Employee Name
Rank
Location
Employee category
Week ending date
Hours
Revenue
Cost
Many to many relationship exists between the tables. I have created a calendar table and a Service line table to help me filter across tables which are created as DIM tables.
The initial output I am looking for will look like the attached image
Output visual
Similar tables to be created based on Team category and Team name
I tried to follow two approaches – first one by maintaining them as separate tables and creating multiple measures for the each of the required fields. However, I was not able to get to the attached table visual
Secondly, I appended the two tables by adding an additional column named Budget and Actuals to the respective tables. Then, Hours, Revenue, Cost was unpivoted and made as the attribute. Measures were created for actuals, revenue = E, forecast, budget and variance. In this scenario, I could recreate the above output. But, could not create revenue per hour and cost per hour metrices
Can someone guide on how to move about this data model.
There are couple of other DIM tables that can be created, but that doesn't save space or is useful in filtering
I have a sql database linked where I have the complete history of products and users. I want to the user to be able to select on the slicer a year and the data automatically shows active prodcuts, expired products and new products added in that year (or snapshot).
Is there a way this can be done? I am not able to find a measure to best do this for me.
I recommend creating a date dimension table first - I usually call mine Calendar. Please read this useful post by Radacad which will show you how to create one > https://radacad.com/power-bi-date-or-calendar-table-best-method-dax-or-power-query
Once it's done create relationships between your fact tables and calendar table on key dates of when your products are active or expired - I'm making a huge assumption that's what your tables store.
Your calendar table will then act as a single time/date point of truth and should be used to slice and dice your fact table.
Hope this helps!
Power BI noob here, still thinking like a SQL coder, so please be patient.
How can I use the user name of the person running the report to filter the report?
As a convenience for my users, I want to provide a way for them to automatically filter to only see data related to their office or region. I have a Person table that includes details like their office location. If I can filter that based on the user name of the person running the report, and join it to the rest of the data, that would work.
Unfortunately, I don't see a way to get the user name in M.
Using the USERNAME() function in DAX, I don't see a way to compare this with individual values in a column. I get an error about being unable to compare a measure to multiple values.
It seems this would be a common request, so I'm sure somebody has solved this problem. But I haven't yet found the solution.
Use a RLS in your model. You can use function USERNAME(),USEROBJECTID (), USERPRINCIPALNAME (); The last one is useful if you have table with users and their email.
https://learn.microsoft.com/en-us/power-bi/admin/service-admin-rls
check also this GuyInCube video:
https://www.youtube.com/watch?v=MxU_FYSSnYU
First, be aware of the differences between USERNAME() and USERPRINCIPALNAME(). Most likely you will want to use the later one.
You can't use neither of these in M. Imagine your model is importing the data. The M code is executed once in the context of one user, then each other user accessing the published report will reuse the already loaded and calculated model. And of course, these are DAX functions, not M.
So in DAX you can use these to compare their values to columns from your model. You didn't gave any information about your model, but lets say there is a table Sales with columns Customer and Amount:
Customer
Amount
Bill Gates#Microsoft.local
100
Steve Ballmer#Microsoft.local
110
In this case, you can write a measure like this:
My Sales = CALCULATE(SUM('Sales'[Amount]), 'Sales'[Client] = USERPRINCIPALNAME())
When Bill Gates opens the report, he will see sales amount of 100, while if Steve Ballmer opens it he will see 110.
For diagnostic purpose, you can make a measure like this and show it somewhere in your report:
Who am I = USERPRINCIPALNAME()
If your goal is to build dynamic Row-Level Security within Power BI, it has some functionality which might help you, so take a look at these articles:
Row-level security (RLS) with Power BI
Restrict data access with row-level security (RLS) for Power BI Desktop
Row-level security (RLS) guidance in Power BI Desktop
Dynamic Row Level Security with Profiles and Users in Power BI : Many-to-Many Relationship
I'm trying to produce a report in Power BI to count the number of groups an individual belongs to. I have a table with users, security groups they belong to, etc.
I'm looking to query the data to help track down users that don't belong to at least two security groups. In my environment every user should be in an All Staff security group plus any other unique group they belong to.
The image I've included has exactly what I'm looking for. I currently don't have that Total column. This is what I need help with. I have the Users and all of the groups they belong to.
Here's a picture of what I'm trying to achieve:
I've tried the Countrows command with a filter but I couldn't get it to filter based on the number of groups users belong to.
I can't simply count the number of times a user's name appears either because this table is a lot bigger than just my example above. This is just an extra feature I'm hoping to achieve out of my table - using the analytics of my report to help find group membership issues and resolve them.
To create the calculated column, you can use this code:
Totals = CALCULATE( COUNT(TableName[Group]), ALLEXCEPT(TableName, TableName[User]))
It groups records by 'User' and then counts number of groups per each user.
I'd recommend though to use measures instead of calculated columns. Measures are much more powerful and useful ways of reporting. To create a measure:
Totals =
SUMX(
VALUES(Data[User]),
CALCULATE(COUNT(Data[Group]))
)
Drop this measure into a matrix or a chart against the users, and you will have the desired report.
In power bi, I have a table Customer in which I am keeping the Id, name and other details of customer. I have another table named Customer_CustomerRole_Mapping which contains CustomerId and its CustomerRoleId. I have another table name CustomerRoles which contains name and id of each role.
CustomerRoles and Customer_CustomerRole_Mapping are linked together.
In Power Bi, I want to show customers count role wise in a pie chart? I tried but I am unable to apply linkage between these tables. I am new to Power Bi.
Your Tables:
Customer
Role
CustomerInRole
The Table "Customer" is not necessary for your Report because you only need to know the count of rows in "CustomerInRole" per row in "Role". So just add a pie chart, use the name of the role in the axis (or legend) and the (distinct) count of Field "CustomerIDs" in "CustomerInRole"
That is all you need ;-)
please find table relation is one-way or two-way . if it is complex and you are going for two way then it will not show.
To have things clear I would add the role to your customer's table. There's no use in keeping things in a relational way when you start playing with BI.
This can easily be done in the query editor. On the home tab, click "Edit Queries"
And there you'll have to click "Merge queries", also on the home tab completely on the right.
In the upper table you select the CustomerID-column and Customer_CustomerRole_Mapping table, select the right ID for that table. After clicking "Ok" you can expand the new columns (by right clicking the merged query-column). You will have to repeat this step to add the roles to the Customer table, but in this second round you will have to work with selectint the roleId's.
After all this you can delete the columns that you don't need anymore from this table and just keep the role.
In the pie chart you then just add the role and select "Count".
It is handy to solve it like this when you have other Fact-tables, and you want to use Role as a Dimension.
You can be linking of tables in power bi desktop go dashboard and click on the third menu as showing in image Relation Management data table image whatever you want make relation with table just drag and drop to link within multiple and single tables with parent and child tables and if you want to delete this relation just go on relation arrow(line) do right click on line and delete it and save file.
Cheers.