how to get x no. columns data from same row to single column with comma seperated - arrays

I want all data from column "A" to single-cell "d5" with comma-separated.
Example:
I have the following data in a sheet.
A1=john
A2=berry
A3=spartan
A4=sparrow
result i need is "john,berry,spartan,sparrow" in cell "d5".
Also, it would be great if I can set the desired no of rows instead of all.
like if required one than = "john" and
if required three than = "john,berry,spartan"

try like this:
=TEXTJOIN(","; 1; A:A)
for 3 use:
=TEXTJOIN(","; 1; A1:A3)

Related

How to separate comma separated and where condition in LINQ

I have a giftcardamounts in database table.
Column contains dollar and comma separated values.
There are 40 rows.
Ex:
row 1: giftcardamounts : ($10,$20,$30,$40,$50)
row 2: giftcardamounts : ($100,$200,$30,$40,$50)
row 3: giftcardamounts : ($10,$20,$300,$400,$500)
...etc
From frontend there is an input is giftcardselectedamount
Ex: giftcardselectedamount=500
Based on this input amount in need to write LINQ query on dollar and comma separated list of Values.
Please help me how to write this.
Like commenters have noted, you should show some effort in reaching to an answer. Also your question isn't quite clear. Are you asking to return the row with a matching amount? If so you can try the following approach, which returns the first row that contains the dollar amount specified:
void Main()
{
var data = new[] {
"$10,$20,$30,$40,$50",
"$100,$200,$30,$40,$50",
"$10,$20,$300,$400,$500"};
var giftcardSelectedAmount = 500M;
var matchingRow = data.FirstOrDefault(x => x
.Split(',')
.Any(v => decimal.Parse(v, NumberStyles.Currency) == giftcardSelectedAmount));
Console.WriteLine(matchingRow);
}
I can easily modify this answer to return all matching rows, a count of occurrences, or a count of rows with occurrences. Let me know if you need any of these modifications and I can modify my answer to add these.

Replacing cell specific seperator in Google Sheets - 21.06.2019 to 21/06/2019

can someone help me in replacing periods with forwarding slashes in sheets?
I have a data set with over 100 thousand rows in sheets,
I have a date-time formatted as such D.M.Y I need to change it to D/M/Y
each row has 7 or so columns based on date-time.
anyways, below is the first 6 rows of column 'A'
so its format is D.M.Y
so I have 100,000 rows of this in column 'A'
Date
21.06.2019
22.06.2019
23.06.2019
24.06.2019
25.06.2019
26.06.2019
I want to turn it into this
Date
21/06/2019
22/06/2019
23/06/2019
24/06/2019
25/06/2019
26/06/2019
I need it in this format as sheet does not recognize the '.' as a separator and it would take an eternity to do it manually, thanks!
A link to my screen below to see the format
check if your dates are valid dates with:
=ISDATE(A2)
if yes use this in B2:
=ARRAYFORMULA(TEXT(A2:A; "dd/mm/yyyy"))
if no you can use:
=ARRAYFORMULA(SUBSTITUTE(A2:A; "."; "/"))
and if you need real dates do:
=ARRAYFORMULA(QUERY(IFERROR(DATEVALUE(SUBSTITUTE(A2:A; "."; "/")));
"format(Col1) 'dd/mm/yyyy'"))
Assuming your data is on Sheet1 in columns A through G.
On a blank tab, say Sheet2, in cell A1, you could use this formula to substitute the . with /.
=ARRAYFORMULA(SUBSTITUTE(Sheet1!A:G,".","/"))
This should give you the substituted values. You could then copy these and paste them as values to Sheet1.
if you want to use macro or script do like this:
function ReplaceDotToSlash()
{
var sheet = SpreadsheetApp.getActive().getSheetByName('YourSheetName');
var lastRow = sheet.getLastRow();
for (var i = 1; i < lastRow+1; i++){
var value1 = sheet.getRange('A'+i).getValue() + "";
sheet.getRange('A'+i).setValue(value1.replace(/\./g, "/"));
}
}

Power BI - How can I visualize percent of rows with a certain value and of those rows, percent with a value above or below a number?

Data
My data looks like this. I want to see a bar chart of the % of rows where column Y/N? contains "Y" and of those rows, the percent that % column contains a value of 7 or above, and the percent where % column contains a value below 7
Something like...
IF [C2:C19] = Y, THEN COUNTIF [B2:B19] >=7
and
IF [C2:C19] = Y, THEN COUNTIF [B2:B19] <7
Sorry if this is unclear or an obvious question!
One way to do this is to create three different measures
first countrows with filter on "Y" and similarly others - then you can bring these values on your bar chart

Anychart tables: How to include thousand separators?

How can I put the text "100.000" in a table in Anychart? When I try to get the string "100.000" in, it is modified to "100".
For a working example see https://jsfiddle.net/Republiq/xcemvm9L/
table = anychart.standalones.table(2,2);
table.getCell(0,0).content("100.000");
table.container("container").draw();
If you want to use such number formatting for the whole table you can define numberLocale in the beginning. If the actual number is 100 and '.' - is a decimal separator and you want to show 3 zeros as decimals, put the following lines before creating the table:
anychart.format.locales.default.numberLocale.decimalsCount = 3;
anychart.format.locales.default.numberLocale.zeroFillDecimals = true;
And then put in the number as:
table.getCell(0,0).content(100);
If '.' - is a group separator and the actual number is 100000, put the following line:
anychart.format.locales.default.numberLocale.groupsSeparator = '.';
And then put in the number as:
table.getCell(0,0).content(100000);
If you want to use special format only for a single cell, we recommend you to use number formatter, which helps to configure all these options only for a single number. For example, it may looks like:
table = anychart.standalones.table(5,5);
table.getCell(0,0).content(anychart.format.number(100000, 3, ".", ","));
table.container("container").draw();
Also, you may learn more about this useful method and find examples in this article

MATLAB Extract all rows between two variables with a threshold

I have a cell array called BodyData in MATLAB that has around 139 columns and 3500 odd rows of skeletal tracking data.
I need to extract all rows between two string values (these are timestamps when an event happened) that I have
e.g.
BodyData{}=
Column 1 2 3
'10:15:15.332' 'BASE05' ...
...
'10:17:33:230' 'BASE05' ...
The two timestamps should match a value in the array but might also be within a few ms of those in the array e.g.
TimeStamp1 = '10:15:15.560'
TimeStamp2 = '10:17:33.233'
I have several questions!
How can I return an array for all the data between the two string values plus or minus a small threshold of say .100ms?
Also can I also add another condition to say that all str values in column2 must also be the same, otherwise ignore? For example, only return the timestamps between A and B only if 'BASE02'
Many thanks,
The best approach to the first part of your problem is probably to change from strings to numeric date values. In Matlab this can be done quite painlessly with datenum.
For the second part you can just use logical indexing... this is were you put a condition (i.e. that second columns is BASE02) within the indexing expression.
A self-contained example:
% some example data:
BodyData = {'10:15:15.332', 'BASE05', 'foo';...
'10:15:16.332', 'BASE02', 'bar';...
'10:15:17.332', 'BASE05', 'foo';...
'10:15:18.332', 'BASE02', 'foo';...
'10:15:19.332', 'BASE05', 'bar'};
% create column vector of numeric times, and define start/end times
dateValues = datenum(BodyData(:, 1), 'HH:MM:SS.FFF');
startTime = datenum('10:15:16.100', 'HH:MM:SS.FFF');
endTime = datenum('10:15:18.500', 'HH:MM:SS.FFF');
% select data in range, and where second column is 'BASE02'
BodyData(dateValues > startTime & dateValues < endTime & strcmp(BodyData(:, 2), 'BASE02'), :)
Returns:
ans =
'10:15:16.332' 'BASE02' 'bar'
'10:15:18.332' 'BASE02' 'foo'
References: datenum manual page, matlab help page on logical indexing.

Resources