how can I operate on the where clause?
For example I have this query
Product::where('purchase_data', '=', $data_inp)->get();
The problem is that I need to operate a formatting on the content of column purchase_data before is compared. What can i do?
Edit to be more specific
The column purchase_data has date values formatted in a certain way, the $data_inp variable is also a date but with another formatting. In order to compare them they have to use the same format; since I can't format the $data_inp variable to the same format of the content of purchase_data, I need to change the format of the content of the purchased_data column before comparing it with the $data_inp variable
Try using whereRaw
https://laravel.com/docs/5.5/queries#raw-expressions
Then you can transform the column to compare.
You can use
Product::whereRaw('purchase_data = '.$data_inp)->get();
Then format the purchase_data to your need
Read more about it here
Related
I have lookup table with one string column and input column from source qualifier is decimal data type. I need to use these two columns in lkp condition. While doing this it is throwing invalid datatype error. So here i need to convert input lookup column datatype. Is anyother way to get this done
Convert your input column in another column in an expression using the function below: TO_CHAR(Your_Column), then link this new column to your lookup.
The datatypes of the 2 columns need to be the same, otherwise how can you expect there to be any matches in the lookup?
You can either convert the string to a decimal or the decimal to a string, whichever is easier
Have you tried to add an Expression transformation that will first transform your input to string then do the lookup after the Exptrans. Try this
I have a table within Power BI that has a date field, and a value field. I am filtering on this date field, using a slicer, to sum all of the value data before the specified date. I would like to get this date value to use in a LOOKUPVALUE() elsewhere (to get a conversion rate).
Is there a way to accomplish this?
I have tried the DAX functions that return the values of a particular table/column with filters preserved but this never seems to work, and just returns the entire dataset, e.g. VALUES(), FILTERS(), ALLEXCEPT().
Any help would be greatly appreciated!
I found a solution using measures.
The DAX for future reference:
Filter Date = CALCULATE(MAX('Table'[Date]),ALLSELECTED('Table'))
I am trying to create an appropriate Format table property of a specific MS Access table in order to achieve the display style described below. For example purposes, let the table name be example and the field that I am trying to format be dollars
When example!dollars.Value is 567.98, I wish to display $0.567K. I also wish to display 1,000.42 as $1.000K.
In another table storing larger values, I use the Format property string $#,##0,\K; ($#,##0,"K)"[Red];"| < $1K |"; --, which successfully displays the amount in K dollars; however, any values less than $1K cannot be displayed. This is not acceptable due to the scale of the values in the example table.
The most intuitive solution is to use the string $0,000\K and specify the thousands separator as . instead of ,. However, I do not know how to do this.
Any advice will be greatly appreciated!
This works for me:
Kamount = Format(Amount/1000, "$0.000K")
So divide by 1000, then format as needed.
Use the Format property string $0\.000\K
I'm stuck with sorting and showing the correct date in Xpages.
It is saved in format "dd.MM.yyyy" and it's a string.
Now why it's a string and formated that way, is because my boss has special wishes. And when I want to sort it from the newest date to older it does something like this:
26.05.2015
24.06.2014
22.04.2015
21.04.2015
20.03.2014
It starts sorting by day.
Is there a way to make it sort it like it should?
I see that i can write a Computed value to Sort column in view column header for date. But i don't know how to even start.
Change the underlying Notes view to get your date column into right order.
Convert the date strings to real date values in views column formula. Assuming your field is called DateText then your formula would be
#Date(#ToNumber(#Right(DateText; 4));
#ToNumber(#Middle(DateText; 3; 2));
#ToNumber(#Left(DateText; 2)))
It would be easier to use just #ToTime(DateText) but this can fail depending on server's local settings. Your date string format would work for a server with German locale settings but not for US. That's why is my suggested solution "safer".
If the date time value doesn't solve your problem and you do not transform your date via #Text (as mentioned in the comments) then create another (hidden) column BEFORE your column that should be displayed. Make this a true date (from your item), sort it and unsort the column to display.
Otherwise use this formula in the newly created sorted column:
#Text(#Year(yourDate))+"-"+#Right("00"+#Text(#Month(yourDate));2)+"-"+#Right("00"+#Text(#Day(yourDate));2)
I have 10 dataset to join.
When I use cogroup, what I get is below
(50637,22284),{(50637,22284,278)},{(50637,22284,308)},{},{},{},{},{},{(50637,22284,17)},{(50637,22284,5)},{(50637,22284,1)}
As seen, grouping identifier is duplicated in each parenthesis.
How can I get the output with the format below ?
(50637,22284,278,308,0,0,0,0,0,17,5,1)
Use FOREACH/GENERATE to select out the fields you want to keep. See http://pig.apache.org/docs/r0.12.1/basic.html#foreach - Nested Projection