Ranking with Pivot table Excel 2007 - excel-2007

I use excel 2007. I have a pivot table with values 'Brands'- Brand Names and the 'Sales' figure of each brand in another column. I want to rank the brands by ascending order of 'Sales'. I do this using 'RANK' function.
But I heard that we can do this using pivot table itself. MS Office blog says how to do this. [Please go through the link].
I did till assigning a value of 1 to new 'calculated field' correctly. But I fail in getting correct result after setting "Running Total In" ('Sales') in the 'Value Field Settings' > 'Show Values As' tab. I get #N/A in each rows where the ranks are expected.
Could any master minds help me to sort this out.. I would be grateful since it will help me in my day to day work.
Thanks in Advance..

Select "Running Total In" ('Brands'), as you want to rank the Brands. It works perfectly.

Related

How to combine rows in BigQuery that share a similar name

i'm having trouble creating a query that'll group together responses from multiple rows that share a similar name and count the specific response record in them.
the datatable i currently have looks like this
test_control
values
test
selected
control
selected
test us
not selected
control us
selected
test mom
not selected
control mom
selected
what i'd like, is an output like the below that only counts the number of "selected" responses and groups together the rows that have either "control" or "test" in the name"
test_control
values
test
3
control
1
The query i have below is wrong as it doesn't give me an output of anything. The group by section is where im lost as i'm not sure how to do this. tried to google but couldn't seem to find anything. appreciate any help in advance!!!
SELECT distinct(test_control), values FROM `total_union`
where test_control="%test%" and values="selected"
group by test_control, values
use below
SELECT
REGEXP_EXTRACT(test_control, r'^(TEST|CONTROL) ') AS test_control,
COUNTIF(values = 'selected') AS values
FROM `total_union`
GROUP BY 1
As mentioned by #Mikhail Berlyant, you can use REGEX_EXTRACT to match the expression and COUNTIF to get the count of the total number of matching expressions according to the given condition. Try below code to get the expected output :
Code
SELECT
REGEXP_EXTRACT(test_control, r'^(test|control)') AS test_control,
COUNTIF(values = "selected") AS values
FROM `project.dataset.testvalues`
group by 1
Output

Running Sum Query

I'm new to Access and I'm trying to develop my own Inventory Management Database.
I'm trying to make a query that could display a running total of the Inventory on Hand as of a specific date. This is how my table looks:
It's sorted according to ITEM_ID then TRANDATE in ascending order. I'd like to add a calculated field beside the NET field that would show a running total of the specific ITEM_ID after a specific date. Negative numbers in the NET field represent a sale while the positive ones represent a purchase. I tried using the DSUM function as it is widely recommended in creating a running sum field. My expression is this
DSum([NET],"InvtyTransT", "[ITEM_ID]=" & [ITEM_ID] And "[TRANDATE]<=#" & [TRANDATE] & "#"). But it only shows the total of the NET field (6827) in each record like this:
What I needed is like this:
(I used an IF function in excel to compute this)
Please help. I think I might have missed something in my expression. I've tried revising it several times and it would always give me the same wrong answer in every record.
Thanks in advance.
Try correlated sub-query.
SELECT t.*, (SELECT SUM(t2.NET)
from InvtyTransT as t2
WHERE (t2.TRANDATE <= t.TRANDATE AND t2.ITEM_ID = t.ITEM_ID)
) AS rSUM
FROM InvtyTransT AS t;

Microsoft Access: Query by Form with Multiple Criteria and Possible Blanks in SQL View

I have started to create a Query by Form using the Form QueryHelp and the Query called DEALLOG3. My goal is for the user to be able to filter by Submarket, Building Type, and a sale date range. With the criteria I have now, it works fine in most scenarios where all of the comboboxes have values. However, when one of the comboboxes is blank, I want to be able to still have the other two criteria working, while showing all of the records for the blank field. (ex: Tampa Submarket, [Blank] Building Type, and a sale date from 01/01/2000 to 01/01/2016).
I've been scouring this sight for the past two days and can't find anything that will work. I think I might be looking for a dynamic query, but I am unsure. Here is what I have currently, please let me know if you can help:
SELECT DEALLOG3.PROPERTY, DEALLOG3.CODE, DEALLOG3.CLOSED, DEALLOG3.Submarket, DEALLOG3.NRA, DEALLOG3.PRICE, DEALLOG3.OCCUPANCY, DEALLOG3.[5 YR IRR], DEALLOG3.PURCHASER, DEALLOG3.SELLER, [PRICE]/[NRA]
AS PSF, [DEALLOG3]![NOI]/[PRICE]
AS [Cap Rate], DEALLOG3.[Building Type]
FROM DEALLOG3
WHERE (((DEALLOG3.CLOSED)
Between [Forms]![QueryHelp]![closeyear1]
And [Forms]![QueryHelp]![closeyear2])
AND ((DEALLOG3.Submarket)=IIf(IsNull([Forms]![QueryHelp]![Submarket]), " * " ,[Forms]![QueryHelp]![Submarket]))
AND ((DEALLOG3.[Building Type])=IIf(IsNull([Forms]![QueryHelp]![BuildingType]),"*",[Forms]![QueryHelp]![BuildingType])))
;
Try again after changing your WHERE clause in
WHERE DEALLOG3.CLOSED Between [Forms]![QueryHelp]![closeyear1]
AND [Forms]![QueryHelp]![closeyear2]
AND (
DEALLOG3.Submarket)=[Forms]![QueryHelp]![Submarket])
OR [Forms]![QueryHelp]![Submarket] Is Null
)
AND (
DEALLOG3.[Building Type])=[Forms]![QueryHelp]![BuildingType]
OR [Forms]![QueryHelp]![BuildingType] Is Null
)

How to make a column invisible in an ssrs matrix

I have an ssrs matrix , the design of which looks like this :
The sql query used in the above dataset looks like this :
select [YEAR], [MONTH] as MONT , ProductName, NumberofSales from XYZ ;
When the report is run , My output looks like this :
Here , the Column Names 9 , 10 correspond to the months 9 - September and 10 - October.
Change shows the difference in numbers between the month and the previous month . example :
number of sales in october - number of sales in september.
I would like to remove the column that I have circled in the above picture . Could you please let me know how I can do this . ??
I already tried right clicking the Change column and changing the visibility property, by adding an expression to look soomething like this :
=(Parameters!UserSelectedDate.Value=Fields!MONT.Value)
But that gives me an entire blank space for the Change column like this :
But I do, not want to see the blank space. I would like to remove the column completely.
Please let me know if it is possible.
I don't know, why it shows blank space, but here is how I handled this problem:
Choose "column visibility" property of column "Change"
Then I added expression for hiding column: =IIF(Month(Fields!Date.Value)=Parameters!UserSelectedDate.Value,True,False)
And when I select report parameter to 1 and preview the report, it hides Change column for month 1:
This answer works only for matrixed (varied count) columns.
But in all reports client want to group report data dynamicly and select column that one want to see.
So if I have matrix for example with columns -
[Store] [Good] [Amount Jan] [Amount Feb].... [Amount Dec]
I can hide any column with Amount but If I right click on column Store - No option in menu- Column properties and option Column Visibility - Disabled. If apply visibility to cells - you'll see a blank space.
I've looked for an answer for this issue and was frustrated that I could not find any. Then I found a workaround for this issue, I decided to share this.
You have to create column groups for all columns, which you would like to Show/Hide. For this matter you have to take or create one or more attributes in you ResultSet, which contain a constant value, so that the columns will not be later propagated.
After you created a new Column Group (as Adjacent Before/After)
you can put there the columns, which you like to Hide/Show.
After that you can use the property "Column visibility". It works just fine for me.

Access 2007 Crosstab Query Expression

Goal: to create a percentage column based off the values of calculated columns.
Here's the SQL code of the Crosstab query:
TRANSFORM Count(Master_Calendar.ID) AS CountOfID
SELECT Master_Calendar.Analyst, Count(Master_Calendar.ID) AS [Total Of ID]
FROM Master_Calendar
GROUP BY Master_Calendar.Analyst
PIVOT Master_Calendar.[Current Status];
This gives me a crosstab query that displays the amount of entries in the database that are "Completed", "In Process", or "Not Started", sorted by which Analyst they belong to.
What I'm trying to do is add another column to calculate the Percent Complete -- so (Completed / Total of ID) * 100. I tried putting that into an expression in another cell, but it returns with a "[Completed]" not found, even though it gives me it as an option in the Expression Builder.
Am I just naming my variables wrong, or is it not possible to do it this way? Can I reference the total count of the records that contain "Completed" using query code instead of finding out the value using a Pivot table?
Thanks for your help.
Try:
SELECT
xTab.Analyst,
[Completed]/([Total of ID]/100) AS [Complete%],
[In Process]/([Total of ID]/100) AS [In Process%],
[Not Started]/([Total of ID]/100) AS [Not Started%]
FROM xTab;