An outer join Excel Power Pivot Pivot table? - excel

I have a PowerPivot with two tables one contains a list of facilities, their type (active/inactive) and whether they belong to org A or org B (FaciltyID|Active/Inactive|ORG)
Another table has a list of users and facitilites assigned to them + their org, so it looks like (userID|FacilityID|ORG) where each userID is repeated the number of times that=the number of facilties it has.
Initially I needed to report the number of facilities active and easily built a PivotTable for it.
Now I need to get a list of the facilities that each user is missing , so I need to basically do an outer join between the the tables for each user and I just can't figure out the way to do it! I joined both table on the FacilityID and am able to see whether they have inactive facilties, but can't figure out a way to show all the facilities they are missing!
Thanks

Nonexistence is hard. This is not the sort of thing that is best solved through measures, but through modeling. In your source, you should cross join Facility and User to get FacilityUser. In FacilityUser, every user has 1 row with every facility, and you add a flag to indicate whether the user is or isn't assigned to that facility. Then your problem becomes one of filtering on that flag value. This is solvable in DAX, but you don't want to do that.

Related

Append a column of a few tables into a single bigger column

I'm having a problem while building this sheet and i'm not being able to find a solution.
The problem goes like this:
This is a marketing agency that wants to build quotes for their clients in a more automated and simpler way they do today.
There is a master table that the user must put all products they have to offer and their prices
from this master table, I've created 5 other tables with power query, So they have an user interface to fill the number of products and price adjustments they want to quote. Also some products price depends on the price and quantity of other products. that's why I needed to separate it.
Now I need to bring them back together so I can use it as a source for a pivot table to build their report.
I've tried a few things:
Making them all a joined source for pivot table, but as they don't have any exclusive fields it failed.
They have a different number of columns and rows, so putting them below each other won't work
I've also tried =Table[Total Value]:Table2[Total Value], but they are joined side by side, and I need them one below each other.
I haven't tried VBA, but it's not out of the question.

Excel 2016 Relationship

Goal
Create a working relationship between my Category Sales and Voids PivotTables so I can leverage one slicer for all data.
Background
Using two PowerQueries, I pull in data from SQL to Excel. Because Sales and Voids have DateStamp and StoreID columns in common, I essentially concatenate these in the SQL query to create an ID. For example:
select concat(StoreID,convert(int,DateStamp)) as ID, DateStamp, StoreID, Category, Sales from...
select concat(StoreID,convert(int,DateStamp)) as ID, DateStamp, StoreID, Voids from...
This is a one-to-many relationship between the two (Sales --> Voids)
Problem
Despite creating the relationship in Excel (through Manage Relationships, as PowerPivot is not available) I can't get it to apply and Excel tells me relationships between tables may be needed. I've no idea what I'm doing wrong.
Workaround
The only workaround I can think of is to take the void value for a given day and divide by the number of categories that have sales, then just do a join to create one table that I pull into Excel. It would technically work for my application, but I'd love to know why the relationship isn't working.
Thanks.
The answer is to export your data into the data model so that you can use power pivot, PLUS a export another power query (or several) into the data model that is a deduplicated table of keys.
Then, in the data model editor, set up the data relationships so that there is a one to many relationship between your deduplicated key table(s) and the "actual data".
Then, in a power pivot, use those "key" tables as much as possible, maybe even to the ruthless ideal(1) of using ONLY key tables in your primary row and column headers, and if you have a second level of categorization then a deduplicated table of primary to secondary, and so on, then using the real data tables only in the body of your power pivot.
(1) - Keep in mind that this is just an ideal I'm just explaining to help you understand and maybe start moving towards as much as actually makes sense. As with most things, in reality, the ideal is almost never worth reaching because there are other factors (like your own patience and time).

Displaying SQL data from multiple tables

I have two tables that hold information needed to display time clock interaction in an excel sheet. The data will need to update with every time clock interaction. I joined the two tables and it was pointed out to me that data duplication is a big no no. Looking for a more simple solution than to do a join everyday so I can have recent interactions. Once I can get the SQL end set up, I can handle the excel side.
Table info:
From the dbo.employees table I need the ID, Last_Name, First_Name
From the dbo.employeetimecardactions I need ID, ActionTime, ActionDate, ShiftStart, Action Type.
ID is the common column between the two tables of course.
If my JOIN statement is needed I will supply, but seeing as the data duplication is a problem I would like to start fresh with NO prior code brought into it.
Also any additional information needed can be supplied if I know exactly what is needed
END RESULT- Excel File that I can share with the powers that be. Contains all recent time clock interactions. Also it would be nice to be able to search by date or employee but that should be an Excel function I would think, and not absolutely necessary
Please check the names of the two tables and correct appropriately, this is based on the first part of this thread and later comments:
SELECT E.EmployeeID, E.First_Name, E.Last_Name, A.ActionTime, A.ActionDate, A.ShiftStart, A.ActionType
FROM Employees E LEFT OUTER JOIN
EmployeeTimeCardActions A ON E.EmployeeID=A.EmployeeID
Here's a WHERE clause to include date. Please check your DB for date format to use:
="WHERE ActionDate BETWEEN '" & TEXT(A2,"mm/dd/yyyy") & "' AND '"&TEXT(B2,"mm/dd/yyyy")&"'"
The formula is in cell C2

SSAS Calculated member that knows if the user is using the report filter

I am trying to write a calculated member which acts differently depending on whether the user is filtering by that member or has it dragged down as rows or columns on their pivot table (using Excel).
The rules are:
1. If the user is using the date dimensin as a Report Filter in Excel, then the calculated member should get the maximum date out of all dates that they are filtered by.
2. If they have the date dimension as rows on the pivot table, then I need to apply ClosingPeriod and some other logic.
Please try this. The idea came from here.
Basically the dynamic named set represents what's in the report filters. And the EXISTING keyword trims the list of days down to the filter context of the current cell letting you detect say if one month is on rows. Compare counts and you can detect what the user did.
CREATE HIDDEN DYNAMIC SET CURRENTCUBE.SelectedDays as
[Date].[Date].[Date].Members;
CREATE MEMBER CURRENTCUBE.[Measures].[My Calc] as
CASE
WHEN SelectedDays.Count > {existing [Date].[Date].[Date].Members}.Count
THEN Tail({existing [Date].[Date].[Date].Members},1).Item(0).Item(0).Name
WHEN SelectedDays.Count < [Date].[Date].[Date].Members.Count
THEN Tail(SelectedDays,1).Item(0).Item(0).Name
END
Performance is going to not be good. And I suspect users will be confused with the results of your calc. If you want to describe the business scenario more I can maybe recommend a better approach.

SSRS Separate Table for each grouping

I have a simple SSRS report which has one group and details. The grouping is by employee and the details are performance data on each. After tedious calculation, it just comes down to
select * from table
and I have SSRS do the grouping on the employee column. There are several tasks for each employee, so that is why the grouping in the first place.
My problem is, the user would like to be able to distribute these stats to the employees, and it would be easier if there were some white space between these groups (between each employee).
I've tried adding a blank row inside or outside the group, but I can't find a way to do that so it won't put a row between each task. I tried using a list, but in the end, got the same problem--the group still forced it to behave that way.
I know I can insert a page break between groups, but that would be a huge waste of paper, having each employee on a separate sheet.
Is there a way to essentially have each employee (group), be in a separate "table"--such that I would have maybe a half dozen on a sheet that could easily be guillotined?
EDIT: Here's a screenshot of it as it is now:
Table
I don't know how I could use a rectangle because the results (groups) are all in the same table. The idea would be to insert a space between each group (person).

Resources