How to sort a Reporting Services table by an auto generated column - sorting

I have this table:
When executed, it looks like:
This table is sorted by alphabetical order. I would like to sort it by the column named "No Vencido", which is generated in runtime combining 2 dimensions of a cube (one dimension is called "Class 1", the other dimension is called "value".
How can i sort a table by an autogenerated field?
Thanks

You can sort by any sort of expression - SSRS will quite happily sort something like two fields concatenated together:
=Fields!Class1.Value & Fields!value.Value
Just be careful to make sure the sorting is applied at the appropriate level to avoid unexpected, i.e. make sure you don't have different sorting expressions in any row group or detail group if not required.
If No Vencido is the grouping expression, apply the sorting at the group level.
If you don't want to sort on an expression, you can create a calculated field for each row in the dataset with the expression =Fields!Class1.Value & Fields!value.Value and group/sort on that calculated field as required.
Edit after comment
OK, I think you need to apply a sort expression like this to the groups that apply to the Top and Otros rows:
=Sum(IIf(Fields!Clase_1.Value = "No Vencido", Fields!Monto.Value, Nothing))
This is still sorting by the total Monto for each row group, but only considering the rows where Clase_1 is No Vencido.
Once this is set up sort by A-Z or Z-A as required.

Related

How do I FILTER cells based on two drop-down list conditions?

I need a FILTER formula to get an output of the cells within the range of the two labels matching the conditions from the two drop-down lists.
For example, given the below sheet, I need the output to be what's highlighted, given the two conditions from the drop-down lists:
I also need to be able to add more date rows, expanding downward.
I've tried using QUERY:
=TRANSPOSE(QUERY(Accounts!B2:F, "SELECT * WHERE B="""&B2&""" ",1))
This only gives me the row of contents (apple, carrot, cake, steak, soda).
Here you can find my solution:
https://docs.google.com/spreadsheets/d/1cWBLLmJx6mTlYrvPRvRE_y9NpBOJj_ILBgXmoB9suv4/copy
Note that when you merge cells, the value is only in the top one or the leftmost one. So if you have multiple rows for each data, you should multiplicate these cells.
I make additional column for this - first date I just copy and below it I insert a formula: (in H5)
=if(isblank(A5),H4,A5) - it says - if cell in column A is empty, take value from above, but if you find something there, put it here. Then I copy this formula down the sheet.
Then it gets easier.
To filter with data validation you have to first find right column using formulas INDEX and MATCH and then filter it against data values in additional column.
Does it work for you?

Sort fields list in Power BI desktop

I need to sort a very long list fields in Power BI that I need in a special order - not the default sort by name/number.
My dataset looks like this:
and I created another table to use for sorting:
I am stuck from here. I think I need to create a relation between the to tables and then use it to sort the field list. But I do not know where to start.
The order I have now looks like this:
Assuming you're sorting in Power Query, then:
1 Sort table SortOrder by column SortOrder:
= Table.Sort(#"Previous Step",{{"SortOrder", Order.Ascending}})
2 Sort table Data by list SortOrder[ColumnName]:
= Table.Sort(#"Previous Step",SortOrder[ColumnName])
EDIT
It seems you're actually asking how to change the order in which fields are displayed in the Fields Pane
This is currently not possible - fields are always displayed in alphabetical order.
You may vote for this feature request: https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/18355429-use-field-order-as-ordered-in-source-query
The only workaround just now would be to rename your fields so they display in your required order - eg:
01_ClmName_A
02_ClmName_C
03_ClmName_E
04_ClmName_B
05_ClmName_Q
06_ClmName_F

Sort table in ssrs for an aggregate field

I have a column that returns me tasks to find out how many there are I do a CountDistinct (id_tarefa). I need to sort the table by this larger field for the lower value of count (), but the SSRS does not accept sorting by field that has aggregate function.
It is possible to do this sort?
Yes it's possible - but you cannot sort the table by using an aggregate function.
The trick is to sort on the Group and not the table. Row Group -> Group Properties then the Sorting tab.

Trying to SORT table on Expression

I have two tables in my report. Grouped on fields DatePaidFinancialYear and then SupplierName.
I have removed both sorts on the groups themselves. There is also no sort on the tablix.
I then have a COUNT IF in one table that does the following -
=Count(IIF(Fields!DaysLateCategory.Value = "Over10Days" , 1, Nothing))
and the below in the other
=Count(IIF(Fields!DaysLateCategory.Value = "Over30Days" , 1, Nothing))
This gives me below -
I want to sort so that the highest number is at the top. I can't work out how to do it.
When I try and sort by my counts via the Tablix - I get the following error -
A sort expression for the tablix 'Tablix5' includes an aggregate function. Aggregate functions cannot be used in data row sort expressions.
Please advise
IRC - you should remove the table sort and sort using the same expression on the Group properties
Excellent. I could have sworn I tried this but obviously not. All working now.
Thanks

Use an Aggregate function in Sort Expression

I have a report which uses a dataset returned from a stored procedure. There are two key columns: Name and Value
I am using this dataset for two tablixes. The first is just a straightforward tablix displaying the data.
The second groups the data based on a Name column. I need to order this data based on the Sum of Value column
However I get the following error:
[rsAggregateInDataRowSortExpression] A
sort expression for the tablix
'table1' includes an aggregate
function. Aggregate functions cannot
be used in data row sort expressions.
Is there another way I can show the data grouped by name and still order it by Sum(Value)?
Instead of sorting on the tablix you need to sort against the row group. Remove the sort on the tablix and then go to the row group properties and put the same sort expression under the sorting section there, this should then work.
OK, I just had to add an extra column for the the Sum value to my query and then use that. Not ideal, but it works

Resources