I've created a table consisting of four StoreKeys and its corresponding values by Importing a DataSet using a MDX Query and subsequently created a table in SSRS.
The table looks like this:
StoreKey Sales %
500 50 %
1111 125 12.5 %
1100 125 12.5 %
1133 125 12.5 %
1114 125 12.5 %
where the latter column is an expression which is implemented as:
=Sum(Fields!Total_Price.Value)/SUM(fields!Total_Price.Value,"DataSet4")
,i.e. I want to calculate how much each store contributed to the total sale during the period as a percentage.
My issue is however, that since the Row Before StoreKey = 1111 is added, it uses that row as well in the calculations, rendering my solution to become vastly inaccurate.
Does anyone have a trick for solving this?
Regards,
Cenderze
EDIT: After snowlockk's comment I've tried the following:
=Sum(Fields!Total_Price.Value)/ReportItems!Textbox57.value
as the expression, this however gave me #ERROR on every row. My initial though was that Textbox57 may be 0, but it was not.
It looks like you don't want to include the data rows that have a blank StoreKey field from your current solution.
You can use an IIF to check for them and use 0 instead.
=Sum(Fields!Total_Price.Value) / SUM(IIF(Fields!StoreKey.Value = "", CDEC(0), Fields!Total_Price.Value),"DataSet4")
I am assuming that your Price is a decimal - if it's an integer, you wouldn't use the CDEC to convert then zero to decimal.
I make with Excel a MSQuery to obtain some fields from a table in MySql what is working fine but there is one column which has in MySQL a time-format and Excel delievers me this in datetime-format.
I can format the cell in Excel so that it shows me the time in format hh:mm that is not the problem but I had to use these fields from the database to do some calculations in Excel which leads to my problem: I can't make a sum over these fields when the sum is greater then 24 hours, because then I get only the value of the hours and not from the days multiplied with 24 (e.g. instead of 25:15 I get only 1:15).
Normally I use for this format [hh]:mm so there will be displayed all values (even for more then 24 hours) but this doesn't work here, because I get a very high value (for example: 1017144:15). The reason for this is, that Excel adds for every field to the time the acrtual date of today (e.g. 12:00 will be 12.01.2016 12:00) and with this for every time in the sum the value for the date will be add additionally.
I tried it with the following statement in the MSQuery:
SELECT
DATE_FORMAT(entry.timeBegin, '%h:%i') AS 'Beginn',
entry.timeEnd AS 'Ende',
TIME(entry.pause) AS 'Pause'
FROM timetable.entry entry<br>
All 3 columns have in the database in MySQL the format hh:mm. Ende and Pause behaves like described above and Beginn is formatted in the right way (just without formatting the field by Excel) but the content of the field has type string and with this, Excel always use 0 (zero) for these fields when calculating with them, so I get allways 0 as sum.
I know that I can build the sum in MySQL, but this is no solution for me because the user could set some filters in Excel and this is to complicated to build in the query, espacially this is only one part of a more difficult construct.
Ok, here are a few examples. 'Beginn' allways delivers 0:00 (as described above) and 'Ende' and also 'Pause' are allways equal together. So we have to consider Ende or Pause with hh:mm and [hh]:mm format:
0:00 leads to 0:00 / 1017144:00
1:30 leads to 1:30 / 1017145:30
20:00 + 3:00 leads to 23:00 / 2034311:00
21:30 + 3:00 leads to 0:30 / 2034312:30
I didn't try PowerQuery because I don't know it till now and I don't know if it is inside of Excel or MS. I don't want to install an additional tool on the PC for every user. If I had only to take it into my Excel-sheet so it could be a solution if it is functions right.
Supplement: I looked after PowerQuery and see that this will bring me problems, because the most users uses MS Office 2010 and the requirement with Excel 2010 is Microsoft Office 2010 Professional Plus mit Software Assurance and the feature Software Assurance is not present in our company.
Added: For more clearness I add a screenshot from Excel:screenshot of Excel
I get column A from SQL displayed in format h:mm.
Column B is the same just in number-format.
D2 and E2 are the Sum from A1:A10 in format h:mm respectively [h]:mm:ss.
D3 and E3 are the Sum from A1:A23 in format h:mm respectively [h]:mm:ss.
As you can see SQL delievers the Time 5:30:00 via MSQuery and Excel shows me 14.01.2016 05:30:00 which I can format in the right way (column A). Building the sum is possible (look D2) as long as it is smaller than 24 hours else I get only the hours (< 24) which are greater than a entire day. The reason for this you can see in D3 and E3.
What can I do to get the right values? I suppose the easiest way would be at the point of getting the data from MSQuery.
I have a database that keeps track of Tech's schedules. I have a report that spits out the schedules grouped by name.
Dane Morris
1/13/2014 2/7/2014
2/10/2014 3/1/2014
2/27/2014 3/2/2014
3/3/2014 3/21/2014
3/22/2014 3/22/2014
3/24/2014 4/11/2014
In the example if you look at Dane Morris there is an overlap in the dates. He ends one on 3/1/2014 but starts one at 2/27/2014
I was wondering is it possible to check the dates before and if it's more than the date I'm checking Id be able to change the fonts of both of them so I can easily identify if there is a discrepancy in the time line of dates.
You can use the DLookUp function to look at next/previous records.
This Microsoft Support article gives some examples
http://support.microsoft.com/kb/210504
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
I'm a bit confused with this one.
I have a Dataset with a BackupDate and a BackupTime as well as a BackupType. The BackupDate is comprised of 12 characters from the left of a datetime string within a table. The BackupTime is comprised of 8 characters from the right of that same datetime string. So for example: BackupDate would be 'December 12 2008' and the BackupTime would be '12:53PM.'
I have added an XY-scatter chart to the report. I've added a 'series' value for the BackupType (so one can distinguish between a Full/Incr/Log backup). I've added a category value of BackupDate and set the Scale for the X-axis from the Min of BackupDate to the Max of BackupDate. I've then added an item to the Values with the Y variable set to BackupTime and the X variable set to BackupDate. The interval for the Y-axis is 12:00AM to 11:59PM and the formatting for the labels is 'hh:mmtt'.
The BackupTime matches the format of the Y-axis. The BackupDate matches the format of the X-axis. 10 entries are retrieved by my Dataset and the Legend is properly populated by the BackupType field.
No points are being plotted on the graph and no markers/pointers are shown if they are enabled. There should be a point on the graph for every point in time of each day there is a backup of a specific type.
Am I missing something? Does anyone know of a good tutorial dealing specifically with XY-scatter graphs and using them in a way I intend?
I am using the 2005 version of SSRS rather than the 2008 version.
Screenshot of what my chart currently looks like:
In case it could be dataset related:
SELECT TOP (10) backup_type, LTRIM(RTRIM(LEFT(backup_finish_date,
12))) AS BackupDate, LTRIM(RTRIM(RIGHT(backup_finish_date, 8))) AS BackupTime
FROM DBARepository.Backup_History
As requested, here are the results of this query. There is a Where clause to constrain the results to a specific database of a specific server that was not included in the above SQL Query.
Log Dec 26 2008 12:00PM
Log Dec 27 2008 4:00AM
Log Dec 27 2008 8:00AM
Log Dec 27 2008 12:00PM
Log Dec 27 2008 4:00PM
Log Dec 27 2008 8:00PM
Database Dec 27 2008 10:01PM
Log Dec 28 2008 12:00AM
Log Dec 28 2008 4:00AM
Log Dec 28 2008 8:00AM
As the data grows, the scatter chart avoids X-axis values if it extends the (floating/numeric) limitations
Open the chart properties->X-Axis tab->Minor tick mark->Numeric or time-scale values...
It should solve your problem.