Formatting Excel Table for Percent of total by specific column - database

I have a table in excel that I'm databasing information in. In this particular excel it is demographic data of students in a certain course across the state of Texas. You can see below that it is filtered by Ethnicity/Hispanic Latino.
Table Screenshot
It's clear to see that the percent row is utter-non sense. What I would really like this last column to do is tell me of what percent all those who took the survey are Hispanic. This becomes tricky because I would like to filter it for all of our "sub-data" as well. So whether I filter it for age, grade, most common language spoken, etc. I'd like to see the percent of that sub data there.
What do I need to do to accomplish this?
Thanks.

Use SUBTOTAL():
=[#Number]/SUBTOTAL(109,[Number])

Related

SQL Server - Mapping table to identify fields to sum

I have a large database of fields around 400, that need to be summed in various different ways.
Currently I do this in Excel with a look up table to identify which field to sum and then use a sum if formula to then sum those columns. How would I replicate this in SQL?
I've seen some examples where you manually type out each field to calculate but this seems very impractical if you are summing up to 300 fields and if there are any changes to that mapping table, then we would have to redo that.
So far my only solution is to copy and paste all the fields to be calculated in excel, and add the correct summation syntax and paste back in to SQL.
Thanks
Lots of ways of doing this;
create a case statement which acts like your sumif and pass the conditions in the case e.g. CASE WHEN amount >=100 THEN SUM(Amount) END as 'New Column'
Create a function and store all your logic in the function similar to above but easy to maintain should your logic change.
if you post your sumif's with a sample I can help you.

Finding difference between columns in column group

I am using report builder to create a report showing a budget for a project. The dataset includes line items for both budget and projected. See below for example rows. I am using a matrix with column group to display budget and projected side by side as well as a row group to show section, category, etc. I need to have a variance column that subtracts projected from budget.
I have scoured the interwebs for solutions but nothing that has worked so far. I feel like there has to be simple solution to this given it is something that could be done in a sql query with zero effort. Most solutions are assuming I have two separate fields, but these are dynamic fields pull out with the column group.
Dataset Row Samples
Type Section Cateogry Phase Task Total
Budget Building Kitchen Pre-Construction Cabinet Hardware $100
Projected Building Kitchen Pre-Construction Cabinet Hardware $220
Report sample
COL GROUP This is the column i want
Budget Projected Variance
+Buidling $100 $220 -$120
+Kitchen
+Pre-Con
EDIT: I tried the below solution without success and have already visited every link provided in the second answer. Maybe there is something I am missing, but I ended up just doing everything in the SQL query and not use Column groups. This is 100% the simplest solution. I am very surprised there is no easy way to reference individual columns in a column group. The below may work for others, but I just could not get them to work for me. Not sure why.
You could add an additional column inside the “Type” group (provided that this is the name of your column group). Set the Column Visibility to hide the column by an expression like
= IsNothing(Previous(Field!Type.Value, “Type”)
Calculate the values for that column as
= Previous(Sum(Fields!Total.Value), “Type”) – Sum(Fields!Total.Value)
That should calculate the difference between the values of the previous type and the current type, and
only show that column for the "Projected" type (when there is a previous type).
On the matrix, you can use the group subtotals to achieve this, you only have to overwrite the SUM operation with an expression that subtract to values. There are many link mentioning how to do that or that can helps you:
How to add calculated column from dynamic columns to a matrix
Adding subtotals to SSRS report tablix
How to write Expression to subtract row Group SubTotals
Reporting in SQL Server – Using calculated Expressions within reports

Transform data into variable amount of columns

I've been struggling with a challenge I've inherited which I think is possible but can't easily see what the solution would be. It's along the lines of the return rows as columns scenario (which I appreciate there are a lot of posts about already but I think this is slightly different). I thought a PIVOT would be useful but I don't need to aggregate any values. The metadata describing each document is defined at folder level so documentID = 1 should be tagged with the values 111, ABC, DEF and GHI.
So I have a table as follows:
Current Dataset:
The aim is to have the data presented as this instead so all the metadata tags for both the folders and document are stored in one row (ultimately I'll be exporting to CSV)
Desired Dataset
I have the same problem. Not worked out completely yet. I have only done it twice now manually. And planning on making a macro.
I work with vertical lookup and sorting and deleting data.
In your case sort the data based on metatag_value, trasnfer all the BBB, CCC, etc to new columns. then write a VLookup in the Metag_value2, etc columns at the AAA row.
Copy/paste the entire datasheet as values to get rid of the formulas, and then delete all the rows without AAA in them.

Make Access Form Update With Buttons

I constructed an Access database for a group of end-users. This database is composed of one table, tblInventory, and several queries for them to edit their data quickly/easily. One of my queries, for example, is:
UPDATE tblInventory SET Amount = Amount-[Enter Amount]
WHERE ((([tblInventory].Equiptment_Name)=[Enter Name]));
This worked great in my opinion, but I have to please the end-user after all. They requested that I make a form and use buttons to update the data in the table for them. I have the form laid out like this:
The Equipment_Name and Amount boxes pull their information from my table, which has categories named that. My Unbound textbox field is where I would like them to be able to enter the number of the given part they would like to take out of inventory. The button should be to run my query above, but instead of prompting for inputs I would like it to use what they entered into the textbox. I've tried many different things and searched many different sites but cannot find what I'm looking for.
P.S Equiptment_Name and Amount are the only 2 datafields in the table besides other fields I have in the table to serve as more lenient ways to search for data when they entered in names. These fields are called things such as Alt_Name1 and have no real relevance to the form.
Thanks in advance for any help given.
There is a couple ways you can do it but the simplest way is:
Build your query as a predefined query(ies)
Build a Macro that disabled warnings then executes your query or queries in the order you wish to execute them.
Go to the form Define the button.
Go to the event tab.
Build an event
Set the OnClick Event to the name of the Macro.
Save and Test.

Need to insert nested totals for text boxes in SSRS List Tablix cell

This article is SOOOOO close: How to create a report with sections and page breaks using SSRS, at this link: How to create a report with sections and page breaks using SSRS. Using a UNION between the tables we can get the vertical hierarchy we want, using the List Tablix. Using a LEFT JOIN between the tables, we can use a regular tablix to get the totals we want but we get all counties first, then all townships rather than as shown, County with its monthly breakdown followed by its townships with their monthly breakdown.
IF we can insert a total, somehow, some way ... it'll work OR if we can get the List Tablix functionality in a full blown Tablix, that should do it.
Need to get totals on these text boxes:
Here is where I need the totals:
Of course the answer was simple -- another developer and I looked at this and he tried another approach -- adding a row and then adding a total. Something like it was tried before but the total arrived at was for every payment.
What can I say? Overthinking is a disease ... find an intervention group! :)

Resources