I've been trying tirelessly to figure out this issue and I cannot seem to make it work...
I am working on a project comparing activity times of some mammalian species and need to run a multinomial model in the nnet package. To do this, I need to convert the timestamp data I have into categories of time. So far, I have tried to use the which() function, strptime, strftime, and some others that I've had little luck with. I have the data both in date and time format, just time format, and just hour format in my csv and cannot figure out how to categorize time with any of these. I'd like to add these categories to my dataset as well so I can see which species were active during which times.
The times I'd like to classify are as follows:
Nocturnal: 10pm-4am
Crepuscular: 4am-8am; 6pm-10pm
Diurnal: 8am-6pm
Any help would be so greatly appreciated!!!!!
Related
This is my first time using amazon quicksight and I am having trouble creating a calculated measure that brings in sales from the year before the one I am evaluating in each row.
Example:
I am looking for the simile to the function CALCULATE (SUM (SALES), PREVIOUSYEAR ()) of PowerBi
I am afraid this is not a complete solution but hopefully it will put you in the right direction.
I started with the following dataset:
In Quicksight, I prepared my data by calculating the Year and Month fields from the Date field of my dataset. I then defined the following calculated field:
lag(sum(SALES), [Month ASC], 1)
I was then able to get the following result:
As mentioned, this is a partial answer as it doesn't work for May 2019 (it should be null/empty instead of 19). It might be easier to work with dates field rather than Month/Year string fields the way I did. I hope this will be of some help.
I have some trouble with getting the correct output of a Eloquent Query.
$checkIn = date(request()->checkin);
$checkOut = date(request()->checkout);
$bookedRooms = App\Booking::whereBetween('checkin', [$checkin, $checkout])->whereBetween('checkout', [$checkin, $checkout])->pluck('room_id');
$availabileRooms = App\Room::whereNotIn('id', $bookedRooms->toArray())->sum('number_of_rooms');
What I have is a checkin and checkout date.
It is a database for a Hotel.
The Hotel has Rooms. There a different types of Rooms, and each Room can exist multiple times. That is set in the Room-table with an integer value of the rooms available in column number_of_rooms
What I want, it the output of the percentage that is still available of a specific Room and the total availability of Rooms in the date range.
I thought that it can be achieved with the code given before, but that can be not.
Can someone help me out? Probably it's simpler then I can think of now..
i looked your code, but could you please tell me one thing. what is the date format of checkin and checkout you getting.
make sure that you getting date format is like 2019-07-04 (YYYY-mm-dd).
i hope this will help you.
EVE Online Manufacturing Spreadsheet
In Batch!F3:G, I'm attempting to break down the data input from columns B3:C to their components (and eventually materials/minerals in I3:J) by using filter to compare results in Engine!P:R. Multiplied of course by the total number of each finished product I need.
I've been trying to figure out ways to arrayformula this together, and even tried quite a few query functions without success. The best I've been able to come up with is to string the actual formula together, appending them with {}, but this gets bloated quickly. I need this to be open ended because I have a tendency to build a lot of things at once. Any help would be appreciated, even just point me in the right direction!
Well, based on my limited knowledge about google sheet, I can only think of one way to do this automatically.
Here's a sheet I constructed based on your sheet.
https://docs.google.com/spreadsheets/d/1AfX8o05gUGPiN5S90w4o0yxuIYjsJRaXsaYUFTJuEPo/edit?usp=sharing
First, on Engine sheet, add one more column which will give you the number of materials required for that part, which is looked up in the PART LIST of BATCH sheet. For this I use VLOOKUP, as you see in D2.
Then on BATCH sheet, query the materials that VLOOKUP return positive, multiply it by the amount of item and then sum them.
This is done by the QUERY used in F3
This method only if you don't have duplicate item in your PART LIST, due to the way VLOOKUP work.
Of course if you want to break the material list further, you can do the same approach..
Trying to work on a system at work that will tell how many error codes were registered by a particular machine on the previous workday. This spreadsheet will need to be able to select only the errors generated on the previous date as this will become a rolling list of data generated across a wide time span. Currently working with the formula
=TODAY(),-1,B2:B17)
where the last array is some shutdown days I've put in to generate a global variable "Yesterday" and trying to use the formula
=COUNTIF(Table1[DateOnly],"="&Yesterday)
to gather the number of records that occurred yesterday.
Can anyone tell me where I'm going wrong?
Found that the issue was when I tried to convert the timestamp in mm/dd/yy hh:mm:ss format to mm/dd/yy and didn't realize that the other information was still hiding in there and confusing the formula. One of my coworkers recommended the use of a ROUNDDOWN function in the use of =ROUNDDOWN(argument,0) to get rid of the time information and just leave me with date.
A few references:
Microsoft's documentation on DATESBETWEEN.
Somewhat similar question, though the answer and derivatives of the formula don't return the correct results.
Microsoft's documentation on TODAY
Per the above Microsoft documentation, I'm trying to get a calculation for the last three months based on today's current date in SSAS Tabular model. First, I have no idea how to use SSAS and my company doesn't provide any learning material, so I've been reading through the MSDN documentation, which may not be the place to start, so if this is wrong, I'd appreciate being told so. For instance, with C# or Ruby, I can test code in a console to see if I get the result that I want, and I don't see how I can do that in SSAS Data Tools' DAX language - this is a GUI which gives users very little power over what they can do (it took me four hours to figure out how to access a dimension's properties). I am definitely a code monkey.
I tried using the below formula (and derivatives of it) because this is what it looks like Microsoft is doing in their example:
3MonthValue:=CALCULATE(SUM([MeasureOne])/SUM([MeasureTwo]),DATESBETWEEN(DateDimension[Date],DATEADD(DateDimension[Date],-3,MONTH),TODAY()))
The result, nothing. Of course, if I run similar SQL logic, I get the right results. I also used the provided SO example, though I suspect that's not exactly what I'm trying to achieve, and only obtained blanks as answers. Given that I need to calculate a formula between a certain time frame, which in SQL would be the WHERE clause, how do I translate this into DAX? In other words, what is DAX's WHERE and if CALCULATE isn't right, what's the correct approach?
When you say it isn't working, how do you mean? The formula you are using refers to your date dimension's key as the starting date for your DATESBETWEEN function - this means if you are expecting the measure to populate a value, you'll need to be using a particular date in your pivot to establish context.
If you are trying to view the measure at design time, in the editor, there is no context so the measure wont populate.
Moreover, if in a pivot you're looking at a time context that includes more than one date, that also will not work. So say you are looking at a month, or a quarter. Both of these encompass what amount to multiple DateDimension[Date]'s - so again context cannot be established.
so to recap - measures which look at date ranges like DATESBETWEEN using a starting time context that is set to your dimensions time key will only show up in a pivot when the pivots data is filtered to a single date.
You can test this using the same function, but hard set the starting date by replacing DateDimension[Date] with a static date (or possibly TODAY()). The measure should show up in design time because the formula has all the information it needs to complete the calculation.