SSRS adding formula to Interval Offset property - ssrs-2012

I am trying to workout the formula for the following. Could someone please help.
= if ReportingMonth= 10, then interval offset = 3,
If ReportingMonth = 11 then interval offset = 1
If ReportingMonth = 12 then interval offset = 2
Note: ReportingMonth is the Report variable.
This needs to be for all 12 months.
Many thanks

I think you need to provide some more information. Without knowing anything about your dataset, it seems like it would be easier to do this in SQL. Pass in the data parameter, then analyze and offset within SQL. If this isn't an option, and you don't know how to get the month, you can use this in VBA:
thisMonth = Month(thisDate)
And then you can offset accordingly. I'm assuming here that you're trying to offset the month, based on the date parameter. Please correct me and provide more information if I'm wrong.

Related

Spotfire Calculation using previous rows calculated data

I have been struggling with the following calculation. I have tried a few previous, next and overs but I cant seem to get the syntax correct.
Basically i need to subtract demand from stock on hand, to get a new column. the the next row will use the newly created column as stock on hand and the subtract the demand for that row, then that result becomes the new stock on hand etc. i cant get it to loop. I have ranked the demand in order of date required per plant. AS the data set will have multiple Plants, SOH and demand.
The attached pic shows A020 only has one QTY short so that is straight forward, but for A030 opening SOH is 152, and the 1st date QTY short is 12, so i need 152-12 = 140. then the second date QTY which is ranked 2, needs to be 140 - 12 = 128, so then rank 3 uses 128 - 12 and so on. ie the SOH needs to dynamically update.
data set
It might not be natively possible in point-and-click Spotfire (happy to be corrected if this is incorrect).
You should consider writing a data function using R to do this groupby-loop operation.

Tableau - Fixed calculated field depending on date filter

I'm new to Tableau. I am trying to make an inventory report which tells the user how much of certain product he/she should buy in advance.
Depending on the amount of days selected on the filter, the difference in days of the complete period should be calculated. For example: If the filtered dates are from 1/03/2021 to 09/03/2021, the result should be equal to 9. The formula I used is the following: date_difference = DATEDIFF("day",MIN(DATE([Fecha])), MAX(DATE([Fecha]))) + 1
The problem comes when I try to use the value given by such date filter. My next calculation should be:
calc = Quantity Inventory / (Units sold / date_difference). Both Quantity Inventory and Units sold are calculated fields in which I have no problem. However, instead of having a fixed value of 9, date_difference changes as shown in the image, giving me incorrect results for the desired calculation.
How can I make sure that the calculated field date_difference has the value of 9 on all rows?. Actually, if I add date_difference field by itself in a different Page it does show the proper value. The problem occurs when calculating calc and trying to add it to the table.
Note: Remember that the value of date_difference will change, depending on the range of time selected on the date filter
Thanks a lot in advance.
Step-1 Use this calculation for date_difference instead
DATEDIFF('day', {min(DATE([Fecha]))}, {max(DATE([Fecha]))}) +1
Step-2 Add Fecha filter to context, by right clicking it in filters shelf.
This will solve your problem. See the GIF

Power BI - Calculate Difference between previous day volume and the next day volume

I have got a table that only contains two column Legend (for Dates) and EOD Volume (for volume) as shown below.
I need to calculate the difference between the previous date volume. For example to calculate the difference between Feb 29 to March 2nd, it will be ((1469-1877) / 1469) * 100%. How to do create this measure in power BI. And the data also contains weekends and weekdays and i will need the analysis for all dates regardless of weekends and/or weekdays. Could someone please help me on this. Thank you in advance.
My propose solution works in a table at day granularity. Additionally, to handle working day the best-practice is to manage it as a binary attribute in the back-end because working days differ country by country so there is no standard dynamic way to handle them.
Possible Solution:=
VAR _YESTERDAY = CALCULATE(MAX('Fact'[EOD Volume]), PREVIOUSDAY('Calendar'[CalendarKey]))
VAR _TODAY = CALCULATE(MAX('Fact'[EOD Volume]))
RETURN
DIVIDE(_TODAY - _YESTERDAY, ABS(_YESTERDAY))

Pulling data from Crystal Reports

My data is stored in Oracle and the only way I can run a report with it is using Crystal Reports. I have a set of data that looks like this ,,,,,,,,,,1, or ,1,,,,,,, or ,1,,,,,1,,,,1,. There are more variations.
Each one means a value is true for a record. There are about 54 'ticks/commas' What I want is all records with the one at the X spot. So for one report I may want all records in the 10th spot that have a 1. There may be other times where I want the records where the 1 is after spot 36. I agree it will pull other records but the main once I want is the X spot.
How do I get this? I tried a Like command but that does not narrow the data down far enough. I am familiar with SQL but not Crystal.
Any help would be great. TIA
In Crystal, you might try setting up a Parameter Field to hold a numeric value (1 to 54) then use that in a formula as the Record Selection. You'll be prompted to enter the parameter when you run the report.
In record selection i was initially going suggest the following which would bring back all records with 1 in the 12 spot. But this makes it hard to bring back a range.
split({yourfield},",")[12] = 1
This will bring back the same
instr({#test},"1") = 12
Then for your suggestion above you could use the following to bring back any record if it has a one in any spot after 36
instr({#test},"1") >= 37
As long as there is only one 1 in the field you can use this for other ranges as well.
Actually I don't want to disturb both answerts by Clayton Morris and CoSpringsGuy hence posting my answer.
You need to combine both the solutions to get the desired result.
Create a number parameter and provide either 1 to 57 numbers or keep just a filed to enter desired number.
Now in record selection use the formula given by CoSpringsGuy
if instr({databasefield.column},"1") = {?Inputnumber} --parameter field
then {databasefield.column}

Openedge syntax for TIME minus 4 hours

I am trying to figure out how to write a Openedge query where i can look back 4 hours. i have struggled with the TIME syntax before. If i understand correctly, the TIME representation in Openedge is in seconds starting from midnight. The query i am trying to write would run 4 times a day, looking back 4 hours.
Is there any way to do this using TIME? Maybe i have to write 4 different queries that only pull records starting at a specific time?
Thanks very much for any help i can get, it is greatly appreciated!
Martin
You don't describe the contents or layout of the table very well.
Yes, TIME, in Progress ABL contains the number of seconds since midnight. So 16:20 for instance is 58800 (16 * 3600 + 20 * 60).
Assuming the field in your table contains an integer representing the time you can do like this to select the records that was created up to four hours ago:
DEFINE VARIABLE iTime AS INTEGER NO-UNDO.
/* I find it easier to write like this but you can very well do = TIME - 14400 instead */
iTime = TIME - 4 * 3600.
FOR EACH tablename NO-LOCK WHERE tablename.createtime >= iTime:
/* Do something */
END.
Note: perhaps you need to check create date as well? And handle midnight?
Another option might be to look at the DATETIME type. There you can do operations like adding and distracting an amount of time.
DEFINE VARIABLE datnow AS DATETIME NO-UNDO.
DEFINE VARIABLE datthen AS DATETIME NO-UNDO.
datnow = NOW.
DISPLAY datnow.
datthen = ADD-INTERVAL(datnow, -4, "hours").
DISPLAY datthen.

Resources