I want to filter using multiple column values from csv. I first want to filter by city and then criticality columns. I would like to filter Criticality (high/medium/low).
How to filter using AND/OR ?
City and Criticality are checkboxes and based on the selections i want to filter the data from the respective csv columns. looking at efficient way of filter.
Can i have something like
(d["Criticality]=="High" || d["Criticality"]=="Low")
currently this is what i am doing:
var City="London";
var strSevText="High";
d3.csv("Status.csv", function(consdata) {
var filtercitydata = consdata.filter(function(d, i)
{
if (d["City"] == City)
{
return d;
}
})
var filtersevdata = filtercitydata.filter(function(d, i)
{
if (d["Criticality"] == strSevText)
{
return d;
}
})
})
My CSV file data :
Application_Id,Application Name,Status,Name,City,Criticality
200009,OARINK,RED,Jen,London,High
200039,3000 DEALING,RED,Marc,London,High
200044,KON,RED,Martin,London,High
200067,D3 MATCHING,RED,Marc,London,Medium
200070,Next Generation,RED,Marc,London,High
200088,ONE,RED,Jonathan,London,High
200097,R-CHECK,RED,Graham,Paris,High
200097,D-CHECK-I,RED,Graham,Mumbai,Low
200107,CON,RED,Cary Fel,Paris,High
You can write exactly what you have as a suggestion in your question:
var filteredData = consdata.filter(function(d)
{
if( d["City"] == "City") || (d["Criticality"]=="High" || d["Criticality"]=="Low")
{
return d;
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With