When trying to find the number of times a word is repeated in a dataset... for example if one column has East Northeast and West, and I am trying to find how many Northeasts there are?
In Javascript:
const column = ['east', 'west', 'northeast', 'west', 'northeast', 'south'];
const frequency = column.filter(word => word === 'northeast').length
the value of frequency here is 2
SQL:
SELECT COUNT(column) FROM dataset WHERE column LIKE '%Northeast%'
C#:
int count = dataSet.dataTable[0].AsEnumerable()
.Count(row => row.Field<string>("Column-A") == "Northeast");
Related
I have a table with order information. It is broken down by OrderID, Item Name. How can I get the count of all orders with multiple x and y items. For example, how many orders have more than 1 dumplings and more than 1 water?
You can use the Countif function like:
countIf (
Revenue,
# Conditions
CalendarDay >= ${BasePeriodStartDate} AND
CalendarDay <= ${BasePeriodEndDate} AND
SourcingType <> 'Indirect'
)
Documentation
I'm new to firebase. I made a game similar to flappy bird, and now I would like to add a leader board.
Could someone help me organize the game score data in firestore so that I can run queries to retrieve:
Top 12 high scores achieved in the last 7 days
Or
Lowest high score recorded in the last 24hrs?
Since these queries contain filters on different fields (score & date) I'm not sure how to do this in firestore.
My initial attempt was to create a collection containing documents, and each document holds playerName, score, date. But it seems I can't query the data if it is formatted this way.
For example If I have 3 documents containing this data:
{ playerName: 'A', score: 500, date: 1649079891803 },
{ playerName: 'B', score: 400, date: 1649079891802 },
{ playerName: 'C', score: 567, date: 1649079891801 },
and I run this query:
query( collection.ref,
orderBy( 'date', 'desc' ),
where( 'date', '>=', last24hrs ),
orderBy( 'score' ),
limit( 1 ),
);
firebase is returning to me playerName A, score 500 rather than Player B score 400 which is the lowest one.
If I make player C's date be the largest in the group of 3, then firebase will return it ...
I'm looking for a query that will return the lowest score in the last day
Okay so I have a table like shown...
I want to use PowerBI to create a new column called 'First_Interaction' where it will say 'True' if this was the user's earliest entry for that day. Any entry that came in after the first entry will be set to "False".
This is what I want the column to be like...
Use the following DAX formula to create a column:
First_Interaction =
VAR __userName = 'Table'[UserName]
VAR __minDate = CALCULATE( MIN( 'Table'[Datetime] ), FILTER( 'Table', 'Table'[UserName] = __userName ) )
Return IF( 'Table'[Datetime] = __minDate, "TRUE", "FALSE" )
Power BI dosnt support less than second so your DateTime Column must be a Text value. Take that on consideration for future transformation.
i just want to sum a column and show in footer but problem is that column sum is depend on other column value.
Example
in my grid i have two column
one for price and second for currency code
Price CurrencyCode
100 Eur
54 GBP
65 GBP
89 USD
41 EUR
i wanted to sum a price according to currency code
show sum in footer Like this
Eur: 141
GBP: 119
USD: 89
how to do this help me..
thanks In Advance
var sumEur = yourtable.compute("sum(Price)",CurrencyCode='GBP');
var sumGBP = yourtable.compute("sum(Price)",CurrencyCode='EUR');
var sumUSD = yourtable.compute("sum(Price)",CurrencyCode='USD');
You'll have to generate this text in your code behind. You can use the DataBound event of the grid if you want access to the data, although I would probably calculate this from the datasource directly.
Using linq you can easily get sums like:
var sumEur = datasource.Where(i => i.CurrencyCode == "EUR").Sum(i => i.Price);
var sumUsd = datasource.Where(i => i.CurrencyCode == "USD").Sum(i => i.Price);
etc.
and then:
string total = String.Format("Eur: {0} GBP: {1} USD {2}", sumEur, sumGbp, sumUsd);
And then just place the total string in your page how and where you want it.
I'm trying to use the Crossfilter example site as a start for my desired graph, but am struggling with creating a non grouped graph that interacts with a grouped graph.
My data is a list of unique employee records:
employee,cnt
john,3
bill,15
fred,30
jill,6
...
I want one graph to show the cnt field grouped by value, analogous to the example's Distance graph. The next graph I want would have a bar for each employee, but instead of grouping them by employee value, I want the graph instead to simply show the cnt value.
Here's what I got going so far; however, this does group-by on both graphs:
// ...
var crossData = crossfilter(data),
all = crossData.groupAll(),
cnt = crossData.dimension(function(d) { return d.cnt; }),
cnts = cnt.group(),
emp = crossData.dimension(function(d) { return d.employee; }),
emps = emp.group();
var charts = [
barChart()
.dimension(cnt)
.group(cnts)
.x(d3.scale.linear()
.domain([0, 15])
.rangeRound([0, 920])),
barChart()
.dimension(emp)
.group(emps)
.x(d3.scale.ordinal().rangePoints([0, 920])
.domain(data.map(function(d) { return d.employee; })))
];
// ...
Make your "emps" group sum by cnt, like this:
emps = emp.group().reduceSum(function (d) { return d.cnt; });
That will give you the sum of the cnt field for each employee. Since you only have one record per employee, you'll just get the value of the cnt field.