ExtJS multisort on specific value - sorting

I have a grid with columns like these:
Name | Status | createdBy | runningSince | extraInformation
I want my grid to be sorted DESC by status - no problem.
But is it possible to show the row of a specific value in createdBy on top, followed by the DESC sorted status-values?
In the docs I found Ext.util.Sorter but even with the listed example, I don't understand how to use this in my case.
Any help will be appreciated.

You can take a look at this example: http://docs.sencha.com/extjs/4.2.2/#!/example/grid/multiple-sorting.html

Related

Perform an OR operation on same field from multiple rows SSRS

I am a beginner trying to achieve a simple operation in SSRS using Visual Studio 2019. I have a query which returns a table as follows
ID | Name | Married
1 | Jack | Y
2 | Jack | N
The number of records might vary depending on the number of results. On the report, I want to display only the field 'Married' once. The value of the field will be determined using an OR operation, i.e. if the field 'Married' is 'Y' for any one record, I want to display a 'Y' on the report.
Assuming the Values are either Y or N, you should be able to use something like
=MAX(Fields!Married.Value)
If you report is grouped by, for example, Name then this will give you the MAX value within each group which is probably what you want.
If this does not help, edit your question and show
Your report design
Row Group panel plus details of grouping
A larger sample of data
Expected results from that sample data

Creating advanced SUMIF() calculations in Quicksight

I have a couple of joined Athena tables in Quicksight. The data looks something like this:
Ans_Count | ID | Alias
10 | 1 | A
10 | 1 | B
10 | 1 | C
20 | 2 | D
20 | 2 | E
20 | 2 | F
I want to create a calculated field such that it sums the Ans_Count column based on distinct IDs only. i.e., in the example above the result should be 30.
How do I do that?? Thanks!
Are you looking for the sum before or after applying a filter?
Sumif(Ans_Count,ID) may be what your looking for.
If you need to always return the result of the sum, regardless of the filter on the visual, look at the sumOver() function.
You can use distinctCountOver at PRE_AGG level to count unique number of values for a given partition. You could use that count to drive the sumIf condition as well.
Example : distinctCountOver(operand, [partition fields], PRE_AGG)
More details about what will be visual's group by specification and an example where there duplicate IDs will help give a specific solution.
It might even be as simple as minOver(Ans_Count, [ID], PRE_AGG) and using SUM aggregation on top of it in the visual.
If you want another column with the values repeated, use sumOver(Ans_Count, [ID], PRE_AGG). Or, if you want to aggregate via QuickSight, you would use sumOver(sum(Ans_Count), [ID]).
I agree with the above suggestions to use sumOver(sum(Ans_Count), [ID]).
I have yet to understand the use cases for pre_agg, so if anyone has concrete examples please share them!
Another suggestion would be to do a sumover + partition by in your table (if possible) before uploading the dataset, then checking if the results matche with Quicksight's aggregations. I find Quicksight can be tricky with calculated fields, aggregations, and nested ifs so I've been doing calculations in SQL where possible before bringing it in to quicksight to have a better grasp of what the outputs should look like. This obviously is an extra step, but can help in understanding how quicksight pulls off calcs and brings up figures (as the documentation doesn't always give much), and spotting things that don't look right (I've had a few) before you share your analysis with a wider group.

Referencing a table given in column as text

this should be an easy question. I'm fairly new to Power Query.
I have a report table, there is a column "Queries" which are names of queries i have in my workbook.
I wish to add a column to count the number of rows in the queries.
The formula i use is =Table.AddColumn(Source, "RowCount", each Table.RowCount([Query]))
My report table would looks like below:
| Queries | RowCount |
| Qry Apple | |
| Qry Orang | |
However I am getting the error:
Expression.Error: We cannot convert the value "Qry Apple" to type Table.
Details:
Value=Qry Apple
Type=Type
Does anyone know how to solve this?
Thanks!
= Table.AddColumn(Source, "Row Count", each Table.RowCount(Expression.Evaluate([Query],#sections[Section1])))
It seems like this is one of those things that requires random obscure knowledge about the structure of PQ. Expression.Evaluate needs to know the "environment" to resolve the string in, and it appears tables in PQ are sitting in a record called [Section1] in a global query called #sections.
I found a solution to this from Chris Webb's BI Blog: Expression.Evaluate() In Power Query/M.
Basically, we need to use Expression.Evaluate in order to read the text in the [Query] column as a table. Note also that you need to include the #shared parameter so it has access to the necessary environment. (For more details, see the linked blog and the references it gives.)
= Table.AddColumn(Source, "RowCount", each Table.RowCount(Expression.Evaluate([Query], #shared)))
Finally, found the answer, after a year of practicing,
I tried using Expression.Evaluate as suggested but to no avail, hence I don't think the function can properly convert a text into a #table. I stand to be corrected.
The solution do make use of #sections, thanks so much for the brilliant idea by #Alexis Olson and #Wedge!
I used the Record.Field function to "Get" the tables into a column as table objects, then finish it off with the Table.RowCount function. For clarity, I split them into two steps.
So here it is:
let
Source = Excel.CurrentWorkbook(),
MyTables = Source{[Name="MyTables"]}[Content],
GetTblObj = Table.AddColumn(MyTables, "MyTables", each Record.Field(#sections[Section1],[Query])),
RowCount = Table.AddColumn(GetTblObj, "RowCount", each Table.RowCount([MyTables]))
in
RowCount

SSRS / Visual Studio: Distribute data into columns based on another field

Is it possible to easily distribute data ('subject's in my case) into different columns based on the value of another field ('block' in my case) so I could have a kind of timetabling grid report, i.e.
if my data looks like:
Subject | Block
----------
English | A
French | B
Science | C
----------
x | A
y | B
z | C
How might I produce a table / matrix that looks like:
Block A | Block B | Block C
English | French | Science
x | y | z
(forgive the formatting!)
I can't help thinking this must be straight forward, but I can't seem to find the appropriate technique. Something like a pivot, but listing rather than aggregating values? I thought maybe filtered columns, but that doesn't seem very efficient. Many thanks for any advice!
Using the following as a basis
https://stackoverflow.com/a/9007678/2311633
(I have copied the relevant sections so the complete answer is on this page...)
You can create a horizontally expanding table by:
First create a Tablix by dragging the Matrix Report Item onto the design surface. The Tablix will have a RowGroup and a ColumnGroup by default.
Delete the Row Group by right clicking on it and selecting "Delete Group" In the Delete Group prompt, delete both just the group. (Not related rows and columns; you'll probably want these as left label for your rows.)
At this point right click the Column Group and "Add Group -> Child Group...". Keep adding child groups for each of the rows you require. For each child group select 'Group by' and choose each of the series you wish to display on each individual row.
I am unable to post images at this time, but have been able to recreate what you have requested above. Once I'm able to I'm can post screenshots for further clarification if required.
Update
Alternatively, If you are able to edit the SQL source could you add another field to define a row number for each item. Using ROW_NUMBER() and PARTITION_BY you could add a new column such as
SELECT ROW_NUMBER() OVER(PARTITION BY [Block] ORDER BY [Block]) as rownum
Then you could just create a simple Matrix as shown here https://www.flickr.com/photos/135805284#N08/20883237722/

Calculate percentage of total columns based on total column in SSRS Matrix

Looking to add a column in my SSRS Matrix which will give me the percentage from the total column in that row.
I'm using the following expression, but keep getting 100% for my percentages (I'm assuming this is because the total is evaluated last, so it's just doing Total/Total?
=FORMAT((Fields!ID.Value/SUM(Fields!ID.Value)), "P")
The field ID is calcuted within SQL, not SSRS.
For example
Site | Value 1 | %1 | Value2 | %2 | Total
1 | 20 | 50% | 20 | 50% | 40
Probably this is happening because you need define the right scope for the SUM function:
SUM(Fields!ID.Value,"group_name") instead of plain SUM(Fields!ID.Value)
Updated:
I needed some time to make an example since I didn't have reporting services available the first time I answered you.
You can see the result and the field values
Hard to provide details without more info on the setup of your groups, but you should look at using the scope option to the aggregate operators like SUM or first:
=SUM(Fields!ID.Value, "NameOfRowGrouping") / SUM(Fields!ID.Value, "TopLevelGroupName")
Also, to keep things clean, you should move your format out of the expression and to either the placeholder properties or textbox properties that contains your value.

Resources