I have a table which tooks like this:
ID_1 Total Active Inactive
124507 4 1 3
124519 4 0 4
124521 4 2 2
I would like to add a column at the end, which would tell me which percentage of the the total are active?
like:
ID_1 Total Active Inactive %
124507 4 1 3 25
124519 4 0 4 0
124521 4 2 2 50
Format(((active) / (total)), Percent)
Reference: http://www.techonthenet.com/access/functions/numeric/format.php
Make a query in query design. Include the table you already have. Drag all the fields from your table to the bottom of the screen where you can put fields to include them in the query. In the next empty box, put:
NameofNewField:Format((tablename.Active)/(tablename.Total), Percent)
This will create a new field in your query, with NameofNewField being the name (change it to whatever you want, but I wouldn't recommend "%"). Also be careful of reserved words, because "Percent" is a reserved word and you'll get an error if you wanted to make that the field name. "tablename" is just the name of your original table.
I included "Format()" in the formula because that way you can just make the query with no other editing, but the better way is to format the field you are making into a percentage into a field that only allows percent, because personally I have problems with Format() sometimes. You can change the field by putting your cursor in the box where you just wrote your formula, then it should show field properties on the right side of the screen where you can change the field to a percent field.
Related
I need to create a report which is something similar to a Pivot Table.
The report would be something like below, with more towns
I C S Total
Town1 1 2 3 6
Town2 7 1 1 9
Town3 2 3 1 6
Total 10 6 5 21
In Crystal reports, there is an integrated function called Cross table
(see pictures below)
I'm looking for a similar function in SSRS, if there is any. I parsed the internet but I could not find anything that is relevant
Thanks!
You need a matrix to do so
Select the row, once the matrix created, like the image below and click on the row group and look at the group properties
You then choose the row for which you want to do the grouping like the image below
Repeat the operations for the column group.
You will need to add additional row and columns for the total.
I will do that for the row. You click the row to highlight it and then click on insert rows. You then choose Outside group below like in the picture below
Repeat the operations for the column group.
To have total, please put the following formula in your row and column created outside of the group SUM(COUNT(Fields!name_of_your_field.Value)) and you have the double entry table.
Let me know through the comments if you have any issues, I'll happy to help.
I created 9 columns each which hold either a 0 or a 1 integer. They exist so that users can toggle certain things on and off. I'd like to get rid of these 9 columns and instead use only one column where i can hold 9 0's and 1's for the 9 things my users will toggle. So say i have 000000000 and my user decides to toggle the first function, how would an update query for table accounts and column toggletimers look like which would change the value to 100000000 and so on for the 9 numbers?
You normally should not merge multiple fields into one in database design (violation of "1NF")
If you really want to, use the bitwise operations: update accounts set toggletimers = toggletimers | (1 << (9-1)) where ...
My report look like below
Region1 Region2 Region3 Region4 Region5 state1 state2 state3 state4 state5
I have created column selection parameter and Region value 0
State value 1
How I need to make changes if I select Region only regions 1 to 5 are displayed, or if I select State only states 1 to 5 are displayed?
Can you please help me guys I have been stuck for 3 days. I tried of selecting using single column selection by using below
expression =iif(instr(Join(Parameters!ColumnSelect.Value,","),"01")>0,false,true)
But i am unable select 5 columns at a time.
I think your expression should be:
= Not(Join(Parameters!ColumnSelect.Value,",").Contains("0"))
I would be applying that as the Column Hidden Expression for the Region columns. A similar expression (with the "0" changed to "1") should work for the State columns.
Set the Hidden Condition of each column individually. Make sure you are selecting the columns under Column Groups in the Advanced Mode of the Grouping Window:
Region Columns Hidden Condition:
=Join(Parameters!ColumnSelect.Value,",") not like '*0*'
State Columns Hidden Condition:
=Join(Parameters!ColumnSelect.Value,",") not like '*1*'
I am using below expression
=IIF(instr(Join(Parameters!ColumnsSelect.value,", "),"0")=0,True,False)
=IIF(instr(Join(Parameters!ColumnsSelect.value,", "),"1")=0,True,False)
It seems I've hit a brick wall in MS Access 2010.
It's kind of hard to explain what I'm trying to achieve, so I'll start with a basic example. Let's say we have two tables: A and B.
A:
ID Price Item
1 5 ABB
2 4 ATV
3 2 CCC
B:
ID Price limit Chosen item
1 3
2 4
3 5
4 6
What I'm trying to achieve is create a Relation from table A to B. Each record in table B has to have associated table A record. It should be based on table A field 'Price' and table B field 'Price limit' in a way that the price of selected record from Table A is lower than the price limit imposed in table B record.
That is, the possible table A records for the first table B record is only CCC, for second - ATV and CCC, while for third and fourth all records are valid.
As far as my limited access knowledge goes, I've figured that I should write a query in "Chosen item" field row source property. I've tried writing it myself, however, without success. Here's what I've come up with:
SELECT [Table A].[ID], [Table A].[Item]
FROM [Table A]
WHERE [Table A].[Val] > [Val];
But it does not work. Could somebody please point me to the right direction?
I think that you want something like this where the dropdown box only contains relevant items:
You can set this up by setting the row source of the combo to say,
select item from ta where price<=forms!tb!pricelimit
And adding a little code
Private Sub Form_Current()
Me.Chosenitem.Requery
End Sub
Note that this method comes with a warning. Usong dropdowns like this on a continuous form can seriously mess up the display of your data on any rows other than the current row. In this case, the display is fine, because the bound column and the data to be displayed are the same, however, if the selection was:
Row Source: select id,item from ta where price<=forms!tb!pricelimit
Bound Column: 1
Column Widths : 0cm;2cm
Data would appear to disappear from records when the selection for the current record produced a list that did not contain IDs for other rows. That is to say, if the selection for the current rows returned IDs 1 and 2 and the next row already had ID 3 chosen, the combo for the next row would appear to empty, and so on down the page.
Example:
there are 3 different number values:
1
2
3
I delete the 2 leaving myself with 1 and 3. How do I change the numbers so that the 3 becomes 2?
1 3 -> 1 2
Keep in mind that I have many numbers so I would like to change them all at once and not one by one. That would take alot of time. Thank you!
If they are simple position codes and you wanted to you could do
delete from mytable where position=2
update mytable set position=position-1 where position>2
If they are id's for something, then this would be bad, as you would do a LOT of updates for potentially related tables.