Forum Discussion
Help with Joining multiple tables in Power BI
- 2 years ago
Sarah,
I think I understand your data better now, thanks for elaborating. Given your additional information, let me explain your original problem a different way:
If a ticket (ex: #1) has three tasks (ex: A, B, C) and three attributes (ex: Change Type = X, Service Line = Y, BackoutPlan = Z) and you expect three lines, I understand intuitively that you want to see the task ID repeated on each line, with each each of the three different tasks on one of the three lines. However, because there are also three attributes associated with your ticket, how do I know which of the three attributes to show on the three lines? It seems your answer is all of them (which makes sense!). As your data model is currently constructed, this is impossible to know or do.
Side note: What SQL would return for this hypothetical ticket #1 above is this. That's not what you're looking for either.
Ultimately this does come down to a data modeling issue. It sounds like attributes are part of the ticket entity and attributes exist at the ticket granularity, so to speak. Put another way, only tickets have attributes. Therefore, they should be denormalized into the same table. Since you have 31 different attributes, what I would end up doing is adding 31 columns in the ticket table with the attribute values for that ticket (and probably removing aggregated values like estimated ticket time from the ticket table, since it looks like they're stored at the ticket task detail level too).
Essentially, what this does is turn the ticket table into a dimension table, while leaving TicketTasks as your one fact table.
Hopefully that makes sense!
P.S.: I have other thoughts on the data model in general, but they don't pertain to this issue so I'll keep them to myself. 😂
----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)
Good Morning Wilson,
Thanks for taking time to look at my stuff. Your explaination makes sense. What I do want is all of the tasks associated with a ticket. In power BI I want the values associated with a couple of the attributes. So in your example of a ticket with three tasks and three attributes, I would expect three records.
Despite that I understand the explanation, I don't know how to fix it as there are no fields in TicketTasks that are directly related to AttributeValues.
In the end, I want a result like this (I've omited fields because they are simple to grab from tickets or tasks):
| Tck_ID | Task_Title | User_FullName | ATTC_Name (associated with Attribute Value when the Attribute = 3884) "Change Type" | ATTC_Name (Assocaited with Attribute Value when the Attribute = 3713) "Downtime" |
So, I do expect mutliple ticket numbers on my report to equal the number of tasks.
The way that the attribute tables work is:
- TicketTasks - tickets themselves do not have date/time. There could be several tasks scheduled for different date/times assoociated with each ticket.
- Attribute = The ID / name of the form fields that users are presented with (ex: change type)
- AttributeChoices = The ID / names of the options for each attribute (ex: Normal, Emergency, etc.
- AttributeValues = The Value that the user selected - this is associated with tickets.
- AV_ItemID = Tck_ID
Is there a way to make it work?
Apologies - this app stripped my nice table, but that was supposed to be four neat columns.