Rows missing from linked Access query - excel

Using Excel 2007, I linked to an Access query using the Data>From Access button, and set it to display as a table. All of the rows are present except any with the Type of 'Placement fee'.
E.g. in the example below, the Free Case Fill deductions show up in the Excel sheet, but the Placement fee deduction doesn't. This query exports fine from Access as Excel format, so it seems to be Excel that is ignoring these rows when linking to it.
Any ideas what can cause rows to be ignored when linking to an Access query?
Chain Account Distributor Warehouse StoreID USDate Type of Deduction TotalValue
Bob's Shops Bob's Shops SMITHS Romeoville KH00463 5/1/2012 Free Case Fill 29.8
Bob's Shops Bob's Shops SMITHS Romeoville KH00463 5/1/2012 Placement fee 2.98
Bob's Shops Bob's Shops JONES Greenwood UN20521 6/1/2011 Free Case Fill 38.81
-edit-
The SQL is below - there are about four or five stacked queries until it gets down to table level.
The placement fees are calculated separately and then added into the rest of the deductions straight from the deductions table, so the only thing I can think of is that they are formatted slightly differently and Excel is ignoring them maybe because the values aren't the same numeric type as the other deductions? But when I export the query directly from Access, everything looks like the same type (i.e. all the values are right-aligned as they are treated as numbers).
SELECT Chain, Account, Distributor, Warehouse, StoreID, USDate, [Type of Deduction], SUM([Total Value($)]) AS TotalValue
FROM (SELECT Chain, Account, Distributor, Warehouse, StoreID, USDate, [Type of Deduction], [Total Value($)]
FROM DeductionsStoresGroupedByMonth
UNION ALL SELECT [Chain/Account/Warehouse], [Chain/Account/Warehouse2], Distributor, [Chain/Account/Warehouse3], StoreID, USDate, [Type of Deduction], [Amount($)]
FROM DeductionsByChainNoStoreID) AS [%$###_Alias]
GROUP BY Chain, Account, Distributor, Warehouse, StoreID, USDate, [Type of Deduction];
-edit 2-
This query (and three others like it) just shows two empty rows when linked as a table from Excel - it is just one column of string, and one column of integers, so no idea what the problem is with this one:
SELECT Deductions.[Distributor's Reference], Count(Deductions.StoreID) AS NumFreeCaseFills
FROM Deductions
WHERE (((Deductions.[Type of Deduction]) Like "*free case fill*") AND ((Deductions.Details) Not Like "*placement fee*"))
GROUP BY Deductions.[Distributor's Reference];

Try ANSI-92 Query mode wild card characters for the Like patterns.
WHERE
Deductions.[Type of Deduction] Like "%free case fill%"
AND Deductions.Details Not Like "%placement fee%"

Related

I want an excel formula to do vlookup multiple times based on the Vlookup results it got for each Vlookup

I have got a ton of bid-related information from the Government E-procurement site in India. I have columns like Ministry, Organization, Department, and Office which are in a hierarchical fashion like multiple offices inside Department with multiple departments inside an organization and organizations inside a ministry. I have a separate list of accounts that have salespeople aligned to it. Now my problem is to find a formula that will help me align the opportunities to each salesperson. I want the formula to go like this, first, it filters out all the results based on Ministry, then out of those filtered results, it filters out the Organization/Department/Office and returns the value from the list of accounts that have salespeople aligned to it. I also want it to skip if Organization is not present and move on to Department.
Sample of data
I tried using VLOOKUP after text-joining Ministry, Organization, Department, and Office, but it matches only the first word and hence the matches are not accurate.
I had a formula passed down to me but couldn't make any sense of it.
=IFERROR(VLOOKUP([#[Organization Name]],ISR_alignment!$G$2:$H$22,2,FALSE),
IFERROR(INDEX(ISR_alignment!$A$2:$A$72922,MAX(IF(ISERROR(FIND(LOWER(
ISR_alignment!$A$2:$A$72922),LOWER([#MDOOA]))),-1,1)*(ROW(
ISR_alignment!$A$2:$A$72922))-ROW(ISR_alignment!$A$2)+1)),""))

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.

Inventory management - find employees with two OR more particular devices

I am managing the inventory of stock for an IT company.
Recently we've had to dole out lots of new iPhones as the old iPhones assigned to employees were incompatible with a particular piece of software.
With most employees working from home and IT staff being split into several different offices it can be a little difficult to co-ordinate things and make sure that the staff member who received a replacement iPhone actually sent back the original one!
It would be great to have an easy means of check for staff who have two (or possibly more) iPhones (any type) so that I can contact them and ask them to return the old device.
I can export the data from the SQL-based equipment database to Excel and analyse it but I don't have the experience to make things more automatic (and build a report).
Here is an example of the database (shown as an Excel file).
In this example case, John Murphy, has got two iPhones. He only needs one of them. Items with the "Employee_Name" set to "IT Service" and have the status set to 'With helpdesk' are in order and do not need to be included in the final report.
'Tammy Top' has only one iPhone and therefore mustn't appear in the report.
Thanks for your help!
UPDATE...
I've played around with Pivot Tables a little... it may be a start. Perhaps if someone is more experienced they could suggest a better way of setting up the values for the pivot table?
I am pretty sure, that there are better solutions.
But at the moment, I can offer you the following:
E2: =IF(AND(A2="IT Service", D2="With helpdesk"),0,COUNTIFS($A$2:$A2,A2,$D$2:$D2,D2))
G2: =FILTER(A2:D6,(E2:E6>1),"")
In column E I used a COUNTIFS formula to check how often an Employee_Name has occured until now. I wrapped it in an IF statement, that checks whether the combination of "IT Service" and "With helpdesk" occured. In that case, it would override the counter with 0.
In column G I used a FILTER formula to provide the relevant rows (A to D) of the source area in case the counter is higher than 1.
Seeing as the data is in SQL Server, just query the database instead of mucking around in Excel.
Something like:
SELECT Employee_Name FROM <table> GROUP BY Employee_Name WHERE COUNT(*) > 1 AND Employee_Name <> 'IT Service'
Should get a list of Employees with more than one phone. To get the full list something like:
SELECT * FROM <table> WHERE Employee_Name IN (
SELECT Employee_Name FROM <table> GROUP BY Employee_Name WHERE COUNT(*) > 1 AND Employee_Name <> 'IT Service')
should get you the list you want.
being the name of the table/view/SP that is generating the data you are importing into Excel.

DAX Rank by Date

I am Counting on Distinct ID's in a column - this is leading to the sum of the subtotals not equalling the grand total as follows:
What I want to do is rank the Payment Dates in cronological order and select ONLY the highest date to display. In the example above the Grand Total won't change, but the Townville row will not show a Distinct Student Count.
This is a very specific requirement and I'm assuming there's an easy way to do it in DAX - I've tried playing around with both RANKX and MAX but am no closer to solving this.
One last thing - the Rank must be contextual to the Time Filter selected by the user (so if they select 2015 it'd give the second record Rank 1 and the top record wouldn't show. If they select May 2015 it'd give the top record Rank 1 and the second record wouldn't show)
I think this is what you are looking for - I added a calculated column to the PowerPivot model that provides a rank based on the Last Payment Date and the Name of the Student. It will rank the earliest payment for any student as a 1.
The code for the column is as follows:
=RANKX(FILTER(Table1, [Student Name] = EARLIER([Student Name])), [Last Payment Date])
... assuming your table is named "Table1"!
The FILTER is the key that limits the ranking to dates belonging to students with that name only.
Update for Multiple tables
To set up relationships between the tables, go to the "Diagram View" of the model, available in the Home tab of the Power Pivot window.
You can drag fields from one table to the other to create relationships. This will only work if at least one of the fields is unique - it's a good idea to think of the model as a dimensional model, with a tables that acts like a fact and other tables around it that act like dimensions.
From the comment, I would try to get the Payments to act like the fact, and have it link to the Community and Student tables. in this case, you could then have the following code:
=RANKX(FILTER(Table1, Related('Students'[Student Name]) = EARLIER('Students'[Student Name])), [Last Payment Date])
This calculated column would be on your Payments Fact table, and it uses a lookup to a related field.
Note that in this specific case, it would be easier to just run the filter over your Student ID field that is used to lookup the Student name.

Exporting an Access database with values from lookup tables

Client is interested in getting data from an Access database in an Excel spreadsheet. This would ordinarily be as simple as going to the Export menu for the table.
This database includes several lookup tables (shown as pulldown menus on the UI form). These values are not represented in the main table as usable text. Also, the drop downs allow multiple choices.
For example,
customer_data - customer demographic info.
lookup_car - stores car descriptions (Pinto, Vega, Reliant Robin, Mustang, Corvette)
junction_car_customer - joins a customer with one or more cars
Customer Jeremy Clarkson (cust_id: 1) owns three cars. The dropdown for his record shows:
Pinto (car_id=100)
Reliant Robin (car_id=101)
Vega (car_id=102)
The junction_car_customer data looks like this:
cust_id car_id
1 100
1 101
1 102
Is there a relatively painless way of exporting to Excel, and having data from the drop downs (values from lookup_car joined in junction_car_customer) placed in a cell as character-separated values?
Is it possible to create a report that will show this information? You're really talking about a simple left join query, and you should just export the results of the query rather than the actual tables.

Resources