Custom sort order in Access report - ms-access

I’m working with a golf database. Most of the reports are grouped by players and sorted by holes 1 to 18.
However, in some cases, I would like to sort the report by holes like 10 11 … 18 1 2 …. 9 (= actual order the holes are played). Again I’m running out of ideas and any help would be appreciated.

You are probably looking for a sort expression like this:
=([hole]+18-[StartHole]) Mod 18

Related

SCCM | How to create a report to show Hardware count and then OS (per HW count)

I never created a report in SCCM and I always used the inbuilt ones but now I need to track my PC's models per OS and I cannot find a report that can help me.
Looking online I found a few posts about counting the total of hardware models but nothing that would have the OS together in it.
Posts like
Posts like
Could you guys help me with this please? the end result would be:
Model Windows 10 Windows 7 Windows Server
DELL model 1 10 20 10
HP model 2 10 67 34
Thanks
Expanding the example you already found, the query would look something like this
select cs.Model0, os.Caption0, count(*) as Count
from v_GS_COMPUTER_SYSTEM cs
left join v_GS_OPERATING_SYSTEM os
on cs.ResourceID = os.ResourceID
group by cs.Model0, os.Caption0
order by cs.Model0
so the solution is to use the so called "grouping sets" and group by more than one property which you joined from another table

how do I find duplicate serial numbers in 2 separate columns in Microsoft access?

I am having an issue with Microsoft access running a query and don't know how to go about running the query I need. i am trying to find duplicate S/N's in 2 columns, for example
COMPUTER SN HARD DR SN MONITOR 1 SN MONITOR 2 SN
1 456 123 654
2 528 234 758
3 963 654 234
as shown above computer 3 is showing the same monitor from both 1 and 2 and I can get Microsoft access to show duplicates from up and down or side by side and I cant figure out how to do diagonal as well. I am using Microsoft access 2016 and any help would be great thank you. I have been looking for the past few days and I don't know what SQL is or how to do that in access but everything I can find shows me how to do up and down (I got that working) or direct side by side (I got that working as well) nothing showing me how to do diagonal as well.
so I had someone else from my work come up and help and we created a query with this in the comment block,
In (SELECT [MONITOR 2] FROM [COMPUTER S/N] WHERE [COMPUTER S/N].[MONITOR 2] NOT IN ("NA")) And Not In ("NA")
and had monitor 1 as the column selected. so it will take each S/N from monitor 1 and check monitor 2 for the same data, then I have to have another query for each column duplicates. the end phrase and not in ("NA") is only to take out the spots where people only have one monitor.

SSRS filtering a series (not a group) or using multiple datasets

I feel like I'm missing something very obvious, but searching hasn't given me a solution and I hope someone can help.
I am working on a simple chart. X axis is the date (day), Y axis is a simple number (1 to 100).
I have totals, for 3 different sites, per day. I need a line for each site on the chart.
Day | Site | Value
---------+--------+-------
Monday | site X | 30
Monday | site Y | 45
Monday | site Z | 20
Tuesday | site X | 35
Tuesday | site Y | 26
Tuesday | site Z | 12
and so on..
There is only 1 total value per day, per site.
I am trying to create 3 lines on the chart, one for each site but I can't figure out how to filter on the series level. (I'm working on a very large date range, so lines work better visually rather than doing a series group of bar charts, or even stacked bar charts)
I originally tried the multiple dataset work around (using an expression and something like
sum(field!total.value, "site X")
but that didn't work (it showed only a straight line, the first value I think) . Now, I have one dataset, but I can't find a way to filter series so they only show for one site.
I also tried this IIF
=iif(Fields!site.Value = "site X", fields!total.value,0)
but that gives a weird looking line.
I can't believe this is not possible in a chart in SSRS, I mean, it's pretty basic, so I must be missing something.
Thank you for your help.
You need to set up a chart as follows
The Values are the actual numbers you are attempting to chart
The Category groups as set up here are the individual dates.
The Series Groups are your Sites
At this point I then set the Horizontal Axis to be in Scalar/Dates format so the designer looks as follows
When you run this report using an adaptation of the (brief) dataset example above you get the following

Simple SQL question - pulling value between min and max

Okay, this is probably really simple but for some reason I'm totally fried on this and need some advice.
I have two columns in my database, budget_min and budget_max.
Oh the front end, I'm trying to build a search that will find everything between two budgets, say 1000 - 2000, or 2000 - 4000.
Need something like where budget_min > 1000 && budget_max < 2000 but that obviously is not the correct query.
Lots of direct options
where (X>22 AND X<55)
also
where X between 22 and 55

Access Expression problem: it's too complex, so how do I turn it in to a function?

Access 2007 is telling me that my new expression is to complex. It used to work when we had 10 service levels, but now we have 19! Great! I've asked this question in SuperUser and someone suggested I try it over here. Suggestions are I turn it in to a function - but I'm not sure where to begin and what the function would look like.
My expression is checking the COST of our services in the [PriceCharged] field and then assigning the appropriate HOURS [Servicelevel] when I perform a calculation to work out how much REVENUE each colleague has made when working for a client. The [EstimatedTime] field stores the actual hours each colleague has worked.
[EstimatedTime]/[ServiceLevel]*[PriceCharged]
Below is the breakdown of my COST to HOURS expression. I've put them on different lines to make it easier to read - please do not be put off by the length of this post, it's all the same info in the end.
Many thanks,Mike
ServiceLevel: IIf([pricecharged]=100(COST),6(HOURS),
IIf([pricecharged]=200 Or [pricecharged]=210,12.5,
IIf([pricecharged]=300,19,
IIf([pricecharged]=400 Or [pricecharged]=410,25,
IIf([pricecharged]=500,31,
IIf([pricecharged]=600,37.5,
IIf([pricecharged]=700,43,
IIf([pricecharged]=800 Or [pricecharged]=810,50,
IIf([pricecharged]=900,56,
IIf([pricecharged]=1000,62.5,
IIf([pricecharged]=1100,69,
IIf([pricecharged]=1200 Or [pricecharged]=1210,75,
IIf([pricecharged]=1300 Or [pricecharged]=1310,100,
IIf([pricecharged]=1400,125,
IIf([pricecharged]=1500,150,
IIf([pricecharged]=1600,175,
IIf([pricecharged]=1700,200,
IIf([pricecharged]=1800,225,
IIf([pricecharged]=1900,250,0)))))))))))))))))))
UPDATE (16/04/10 14:46 GMT)
I've built a new table as recommended below. Now it's matter of removing my expression and making my original SELECT query use the new table. However, I'm not at all clear on how this is done.
Using the DLookUP example I imagine I keep the original query where I have my PRICECHARGED field, include a new DLookUp field that uses the example below to refer to the PRICECHARGED and populate the rows with the appropriate SERVICELEVEL (hours).
I become confused at this point because in my original SELECT query all the calculation happened in that query (expressions, after expression), which meant that the final result of my query was a list of colleagues with HOURS, and REVENUE (Cost) against their name. I have a feeling that I'm in need of another query in the middle to manage the DlookUp process.
`Any directions or road map very much appreciated.
Final update. Added another table as mentioned above, created the appropriate links from the new table to the field in the 'fixed'table. Voila. It worked a charm, and without me doing anything that caused it to crash or give me an error warning. It was easier than I thought. I don't understand why I didn't manage it this way before.
Thanks again, Mike
You're making life really, really, really hard for yourself.
Create a table PriceToHours with columns PriceCharged and Hours. Put the appropriate rows into it so it matches the tabular data in your expression. Now JOIN that table to your main data table to get the Hours from the PriceCharged. When this information changes in the future, simply update the data in the table. This is much more transparent (no data hidden in a query expression) and requires no additional programmer time when the values change in the future.
I would suggest changing the way this works and keeping the service level to price charged logic in a separate table. This would allow you to change it quickly if the business need changed.
The table would just be as simple as two columns and “ServiceLevel” and “PriceCharged”. Then in your query link that to your table.
For a quick check however what would happen in the price charged was say 1105 i.e. not in the list? The function would possibly return a null which would then cause the expression to fail maybe that is causing it?
EDIT::
After a bit of searching around it looks like the maximum number of nested IIF statements in access is 10 hence why it worked fine before but now does not. Looks like your only option is to redesign it to how it should have been in the first place!
Put all the data into a table and do a dLookup! Here is a table called CostHours
Cost Hours
---- ------
100 6
200 12.5
210 12.5
300 19
400 25
410 25
500 31
600 37.5
700 43
800 50
810 50
900 56
1000 62.5
1100 69
1200 75
1210 75
1300 100
1310 100
1400 125
1500 150
1600 175
1700 200
1800 225
1900 250
And to get the hours from the cost, here is a dLookup
dLookup ("Hours", "CostHours", "Cost=" & 100)
This will return the hours where the Cost is 100. Use that value in your calculations.
The beauty of MS Access is that dLookup can sit in the same place you do your calculations - in code, in a report, in a query.
Instead of a DLookup, you can do this in a SQL Statement as well
"SELECT Hours From CostHours Where Cost" = & CostVariable