I am trying to sort a column in SSRS by the Font Color of that column, but am unable to grasp how... The color code that I have developed works as such.
=Switch(Fields!Prk_name.Value = "Lot 1", "DarkGoldenrod",
Fields!Emp_default.Value = "L" OR Fields!Emp_default.Value = "B", "Black",
Fields!Emp_default.Value = "C" AND Fields!Perm_prk.Value = "Y", "Green",
Fields!Emp_default.Value = "C", "Purple")
What I was think of running under the SortExpression is this:
=Switch(Fields!Name.Color = "DarkGoldenrod" SortExpression (),
Fields!Name.Color = "Black" SortExpression (),
So on and so forth just don't know what to put for SortExpression? I would need a way to sort for all 4 color types the base form of this is group by color then sort ABC.
Chris Lätta's post gave me an idea I gave that a try still does not work, but it might help to narrow down what I am looking for.
=Switch(Fields!Name.Color = "Darkgoldenrod", 1,
Fields!Name.Color = "Purple", 2,
Fields!Name.Color = "Black", 3,
Fields!Name.Color = "Green", 4,
True, 5)
Just sort by a number as your first sort expression:
=Switch(Fields!Prk_name.Value = "Lot 1", 1,
Fields!Emp_default.Value = "L" OR Fields!Emp_default.Value = "B", 2,
Fields!Emp_default.Value = "C" AND Fields!Perm_prk.Value = "Y", 3,
Fields!Emp_default.Value = "C", 4,
True, 5)
then add another sort criteria to sort by the ABC column.
Related
I have two dictionaries:
name = ["A","B","C","D","E"]
number = ["1","2","3","4","5"]
How can I produce the following, using built-in functions?
[
{name : "A", number: "1"},
{name : "B", number: "2"},
{name : "C", number: "3"},
{name : "D", number: "4"},
{name : "E", number: "5"}
]
The desired result you have shown is not a single dictionary, but an array of dictionaries, i.e. [[String: String]].
You can convert the two arrays like this:
name = ["A","B","C","D","E"]
number = ["1","2","3","4","5"]
let result = zip(name, number).map { ["name": $0, "number": $1] }
However, I would suggest you create a struct/class for storing these name/number pairs, rather than using an array of dictionaries:
struct Foo { // give this an appropriate name!
let name: string
let number: String
}
let result = zip(name, number).map { Foo(name: $0, number; $1) }
I have a google sheet that contains 8 sheets that needs data to be sorted upon entry. I have been able to modify a script to auto sort each individual sheet, but I need to exclude Rows 1 and 2 from the sort. I am fairly new to using scripts so any help is appreciated. Basically, as data is entered onto a Master Sheet it is sent to the Events Pages (Event 1-Event 8). From the pages I would like the data to be sorted by Column A, but exclude Rows 1 and 2.
function AutoSortOnEdit() {
var sheetNames = ["Event 1", "Event 2", "Event 3", "Event 4", "Event 5",
"Event 6", "Event 7", "Event 8"];
var ss = SpreadsheetApp.getActiveSpreadsheet();
sheetNames.forEach(function(name) {
var sheet = ss.getSheetByName(name);
var range = sheet.getRange(2, 1, sheet.getLastRow() - 1,
sheet.getLastColumn());
range.sort({column: 1, ascending: true});
});
I would like each sheet to auto sort Column 1, but exclude the first two rows. I have been able to get most of the script to work, but cannot figure out how to exclude Rows 1 and 2.
My result with this script is that each sheet will sort, but it includes the first two rows
How about this modification?
When you want to sort rows excluded row 1 and row 2 of each column by Column (A), the range is getRange(3, 1, sheet.getLastRow() - 1, sheet.getLastColumn()).
In the case of getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn()), only row 1 is excluded.
So can you try the following modification?
From :
var range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
To :
var range = sheet.getRange(3, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
Reference :
getRange(row, column, numRows, numColumns)
If I misunderstand your question, I'm sorry.
shoppingList[4...6] = ["Bananas", "Oranges"]
Don't use subscript syntax to append a new item to an array.
But I realize append one or more new items to array with ranges successed. For example:
var shoppingList : Array<String> = ["Bread", "Milk", "Blackingbar", "Chian", "baba", "Oppo", "Xiaomi"]
shoppingList[4...6] = ["Bananas", "Oranges", "Huewei", "5", "6"]
for obj in shoppingList {
print(obj)
}
Why we have recommeded "don't use it" ????
The precise quote from the documentation is
You can’t use subscript syntax to append a new item to the end of an
array.
Your code example replaces three items at index 4 - 6 with five other items simultaneously which is something different. As far as the subscripted range is not out of bounds the operation succeeds.
Im not sure why you would want to make 5 items replace the last 3 but if you need to do it, you could do this:
var shoppingList : Array<String> = ["Bread", "Milk", "Blackingbar", "Chian", "baba", "Oppo", "Xiaomi"]
shoppingList = shoppingList[0..<4] + ["Bananas", "Oranges", "Huewei", "5", "6"]
I need to show some specific options in a dropdown list on top and should sort other options in alpha order. For example if the list is,
["CANADA", "PORTUGAL", "AUSTRALIA", "USA", "BRAZIL"]
I need to show the dropdown list as (usa and portugal as per requirements on top of the list and others in alpha order.)
["USA", "PORTUGAL", "AUSTRALIA", "BRAZIL", "CANADA"]
list = [2,1,3,4]
list = [list.delete(4)] + list.sort
puts list.inspect
# [4, 1, 2, 3]
I Have a Enum
public enum ProcessStatus: byte
{
NotStarted = 0,
PreCheckStarted= 1,
PreCheckCompleted= 2,
Processing= 3,
Failed= 4,
Completed= 5,
Closed= 6
}
in Table we have entries like 0,3,5,6
we need list of Enums based on some criteria and criteria is List which contains 0,1,2
i am able to get all Enums as List Like
Enum.GetValues(typeof(ProcessStatus)).OfType<ProcessStatus>()
and have
List<byte> processListIDs
which contains IDs
i want
IEnumerable<ProcessStatus> filtered based on ids in processListIDs using LINQ.
Thanks in Advance
You can use Intersect with better performance:
var enumList = Enum.GetValues(typeof (ProcessStatus))
.OfType<ProcessStatus>().Cast<byte>();
var result = enumList.Intersect(processListIDs)
.Cast<ProcessStatus>();
var res =
processStatusCollection.Where(item => processListIDs.Contains((int)item));
You could use Enum.TryParse<TEnum>:
List<byte> processListIDs = new List<byte>() { 0, 3, 5, 6 };
ProcessStatus ps = ProcessStatus.NotStarted;
IEnumerable<ProcessStatus> status = processListIDs
.Where(p => Enum.TryParse<ProcessStatus>(p.ToString(), out ps))
.Select(p => ps);
Try this,
var p = new List<byte>() { 1, 2, 3, 4, 6 };
IEnumerable<ProcessStatus> result = p.Select(o => (ProcessStatus)Enum.Parse(typeof(ProcessStatus), o.ToString()));
/// do something with result