Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
So my current application uses MongoDB which isn't natively supported by PowerBI but we usually expose the data via BI Connector and run all our reports by connecting thru the ODBC driver.
I've been tasked with creating a report for what each employees value is for each day they are employeed. This data would be a mash up of 2-3 different tables.
Table 1 - Available
Table 2 - Outage
Table 3 - Assignment
Here's an idea of what I picture my final table would consist of based on the 2-3 Tables listed above.
I'm hoping I'm getting this all out in words properly. I created a PBIX with sample data for you to view
https://drive.google.com/open?id=1RgnpOYuZPyxafSJu0Kmh6i6EZZzj-UEp
Final Table Idea
Date pID Value For Day
12/1/2018 | 1 | Sick |
12/1/2018 | 2 | Hard Labor |
12/1/2018 | 3 | Hard Labor |
12/2/2018 | 1 | Sick |
12/2/2018 | 2 | RDO |
12/2/2018 | 3 | Driver |
12/1/2018 | 4 | Admin |
12/2/2018 | 4 | Admin |
12/1/2018 | 5 | No Assignment |
12/2/2018 | 5 | No Assignment |
Table 1 - Available
Date pID
12/1/2018 | 1 |
12/1/2018 | 2 |
12/1/2018 | 3 |
12/2/2018 | 1 |
12/2/2018 | 2 |
12/2/2018 | 3 |
12/1/2018 | 4 |
12/2/2018 | 4 |
12/1/2018 | 5 |
12/2/2018 | 5 |
Table 2 - Outage
DatePIDOutage.0.TypeOutage.0.StartOutage.0.EndOutage.1.TypeOutage.1.StartOutage.1.End
12/1/2018 | 1 | Sick | 11/1/2018 | 12/2/2018 | RDO | 12/2/2018 | 12/2/2018 |
12/1/2018 | 2 | ||||||
12/1/2018 | 3 | RDO | 12/1/2018 | 12/1/2018 | |||
12/2/2018 | 1 | Sick | 11/1/2018 | 12/2/2018 | |||
12/2/2018 | 2 | RDO | 12/2/2018 | 12/2/2018 | |||
12/2/2018 | 3 | ||||||
12/1/2018 | 4 | ||||||
12/1/2018 | 5 | ||||||
12/2/2018 | 4 | ||||||
12/2/2018 | 5 |
Table 3 - Assignments
DatePIDType Of WorkAssignment Type
12/1/2018 | 2 | Hard Labor | |
12/1/2018 | 2 | Admin | Diverted |
12/1/2018 | 4 | Admin | |
12/1/2018 | 3 | Hard Labor | |
12/2/2018 | 3 | Driver | Diverted |
12/2/2018 | 4 | Hard Labor | |
12/2/2018 | 4 | Admin |
Solved! Go to Solution.
Hi @thmonte,
Yes, I need that table to return correct one when one user has multiple assignment or outage records.
I add two rank tables with type ranking:
Formula:
Desc Based on Rank = VAR assigList = CALCULATETABLE ( VALUES ( Assignment[PID] ), FILTER ( ALL ( Assignment ), [Date] = EARLIER ( Summary[Date] ) ) ) VAR outList = CALCULATETABLE ( VALUES ( 'Outage Unpivoted'[PID] ), FILTER ( ALL ( 'Outage Unpivoted' ), [Date] = EARLIER ( Summary[Date] ) ) ) VAR outRecord = COUNTROWS ( FILTER ( 'Outage Unpivoted', [PID] = EARLIER ( Summary[PID] ) && [Date] = EARLIER ( Summary[Date] ) ) ) VAR assigRecord = COUNTROWS ( FILTER ( 'Assignment', [PID] = EARLIER ( Summary[PID] ) && [Date] = EARLIER ( Summary[Date] ) ) ) VAR assiglistMatch = CALCULATETABLE ( VALUES ( Assignment[Type Of Work] ), FILTER ( 'Assignment', 'Assignment'[PID] = EARLIER ( Summary[PID] ) && 'Assignment'[Date] = EARLIER ( Summary[Date] ) ) ) VAR outlistMatch = CALCULATETABLE ( VALUES ( 'Outage Unpivoted'[Outage Type] ), FILTER ( 'Outage Unpivoted', 'Outage Unpivoted'[PID] = EARLIER ( Summary[PID] ) && 'Outage Unpivoted'[Date] = EARLIER ( Summary[Date] ) ) ) RETURN IF ( NOT ( [PID] IN UNION ( assigList, outList ) ), "Not Assignment", IF ( assigRecord > 0, IF ( assigRecord >= 2, LOOKUPVALUE ( 'Assignment Rank'[Assignment Type], 'Assignment Rank'[Rank], MINX ( FILTER ( 'Assignment Rank', 'Assignment Rank'[Assignment Type] IN assiglistMatch ), [Rank] ) ), FIRSTNONBLANK ( assiglistMatch, [Type Of Work] ) ), IF ( outRecord > 0, IF ( outRecord >= 2, LOOKUPVALUE ( 'Outage Rank'[Outage Type], 'Outage Rank'[Rank], MINX ( FILTER ( 'Outage Rank', 'Outage Rank'[Outage Type] IN outlistMatch ), [Rank] ) ), FIRSTNONBLANK ( outlistMatch, [Outage Type] ) ) ) ) )
Result:
Regards,
Xiaoxin Sheng
HI @thmonte,
I create a summary table based on available table and add a calculated column to stored lookup result from other tables.
Desc = VAR assigList = CALCULATETABLE ( VALUES ( Assignment[PID] ), FILTER ( ALL ( Assignment ), [Date] = EARLIER ( Summary[Date] ) ) ) VAR outList = CALCULATETABLE ( VALUES ( 'Outage Unpivoted'[PID] ), FILTER ( ALL ( 'Outage Unpivoted' ), [Date] = EARLIER ( Summary[Date] ) ) ) VAR outRecord = COUNTROWS ( FILTER ( 'Outage Unpivoted', [PID] = EARLIER ( Summary[PID] ) && [Date] = EARLIER ( Summary[Date] ) ) ) VAR assigRecord = COUNTROWS ( FILTER ( 'Assignment', [PID] = EARLIER ( Summary[PID] ) && [Date] = EARLIER ( Summary[Date] ) ) ) VAR assiglistMatch = CALCULATETABLE ( VALUES ( Assignment[Type Of Work] ), FILTER ( 'Assignment', 'Assignment'[PID] = EARLIER ( Summary[PID] ) && 'Assignment'[Date] = EARLIER ( Summary[Date] ) ) ) VAR outlistMatch = CALCULATETABLE ( VALUES ( 'Outage Unpivoted'[Outage Type] ), FILTER ( 'Outage Unpivoted', 'Outage Unpivoted'[PID] = EARLIER ( Summary[PID] ) && 'Outage Unpivoted'[Date] = EARLIER ( Summary[Date] ) ) ) RETURN IF ( NOT ( [PID] IN UNION ( assigList, outList ) ), "Not Assignment", IF ( assigRecord > 0, IF ( "Admin" IN assiglistMatch, "Admin", CONCATENATEX ( assiglistMatch, [Type Of Work], "," ) ), IF ( outRecord > 0, IF ( "Sick" IN outlistMatch, "Sick", CONCATENATEX ( outlistMatch, [Outage Type], "," ) ) ) ) )
In add, I'm still not so clear for the ranking order of different types, can you please provide more about this?
Regards,
Xiaoxin Sheng
This looks like a great start but the ranking order I'd like to create is what value to show in the Desc column if multiple values existing in any of the other columns.
For example:
If there is 3 records for one person in the Outage table with the following Outage Types:
then I would always want Sick to show as the value. So maybe a seperate reference sheet with all possible Outage Types and Work Types simlar to this
Outage Type | Rank |
Sick | 1 |
Vacation | 2 |
RDO | 3 |
Jury Duty | 4 |
Then if the person has multiple records in either table it can reference this table and always take the lowest ranked value
so if someone has 2 records Jury Duty and Vacation - It will display Vacation since it is lower rank.
Hi @thmonte,
Yes, I need that table to return correct one when one user has multiple assignment or outage records.
I add two rank tables with type ranking:
Formula:
Desc Based on Rank = VAR assigList = CALCULATETABLE ( VALUES ( Assignment[PID] ), FILTER ( ALL ( Assignment ), [Date] = EARLIER ( Summary[Date] ) ) ) VAR outList = CALCULATETABLE ( VALUES ( 'Outage Unpivoted'[PID] ), FILTER ( ALL ( 'Outage Unpivoted' ), [Date] = EARLIER ( Summary[Date] ) ) ) VAR outRecord = COUNTROWS ( FILTER ( 'Outage Unpivoted', [PID] = EARLIER ( Summary[PID] ) && [Date] = EARLIER ( Summary[Date] ) ) ) VAR assigRecord = COUNTROWS ( FILTER ( 'Assignment', [PID] = EARLIER ( Summary[PID] ) && [Date] = EARLIER ( Summary[Date] ) ) ) VAR assiglistMatch = CALCULATETABLE ( VALUES ( Assignment[Type Of Work] ), FILTER ( 'Assignment', 'Assignment'[PID] = EARLIER ( Summary[PID] ) && 'Assignment'[Date] = EARLIER ( Summary[Date] ) ) ) VAR outlistMatch = CALCULATETABLE ( VALUES ( 'Outage Unpivoted'[Outage Type] ), FILTER ( 'Outage Unpivoted', 'Outage Unpivoted'[PID] = EARLIER ( Summary[PID] ) && 'Outage Unpivoted'[Date] = EARLIER ( Summary[Date] ) ) ) RETURN IF ( NOT ( [PID] IN UNION ( assigList, outList ) ), "Not Assignment", IF ( assigRecord > 0, IF ( assigRecord >= 2, LOOKUPVALUE ( 'Assignment Rank'[Assignment Type], 'Assignment Rank'[Rank], MINX ( FILTER ( 'Assignment Rank', 'Assignment Rank'[Assignment Type] IN assiglistMatch ), [Rank] ) ), FIRSTNONBLANK ( assiglistMatch, [Type Of Work] ) ), IF ( outRecord > 0, IF ( outRecord >= 2, LOOKUPVALUE ( 'Outage Rank'[Outage Type], 'Outage Rank'[Rank], MINX ( FILTER ( 'Outage Rank', 'Outage Rank'[Outage Type] IN outlistMatch ), [Rank] ) ), FIRSTNONBLANK ( outlistMatch, [Outage Type] ) ) ) ) )
Result:
Regards,
Xiaoxin Sheng
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
88 | |
86 | |
83 | |
65 | |
49 |
User | Count |
---|---|
127 | |
108 | |
88 | |
70 | |
66 |