Row Number in SSRS gives random number because of grouping - sql

In SSRS when I am grouping by the Risk Description column. So the Rank column is completely messed up. I tried expression =RowNumber(Nothing) but still - no luck
My data in SSMS looks like on a picture below.
What would be the workaround for that?

This expression made the job:
=RunningValue(CountDistinct("YourTableName"),Count,"YourTableName")

Related

Get Sum of Data from Second Dataset in the Second Tablix of SSRS report with Report Builder

I have two different dataset which has a common value placed in two different Tablix in Report Builder tool. I want to achieve a SUM of ELEC_DATA in the second Tablix.
I have already tried using this expression.
=LOOKUP(Field!COMP_ID.value,Field!COMP_ID.value,Field!ELEC_DATA.value,"DATASET2")
The result shows nothing at all -- no errors as well.
Then I tried with custom code.
=code.sumlookup(LOOKUPSET(Field!COMP_ID.value,Field!COMP_ID.value,Field!ELEC_DATA.value,"DATASET2"))
The Result I am getting is "0".
The expected result would be the addition of ELEC_DATA like shown in the pic attached
Looks to me like you're using the LOOKUP function incorrectly. The LOOKUP function only requires 4 parameters to be used.
=LOOKUP([SourceValue], [DestinationValue], [LookedUpValue], "[SourceDataset]")
However, I'm not sure this is the best or even a viable solution to your issue. Honestly, this would be much easier if you were able to combine these two datasets into a single dataset query.
SELECT PAC2_ID, A.COMP_ID, DATE, ELEC_DATA
FROM TABLE1 A JOIN TABLE2 B ON B.COMP_ID = A.COMP_ID
From there, you can use a Grouping on the second Tablix based on PAC2_ID which removes the need for any expressions. It should sum the values automatically when you apply the grouping.
Alright Let's try something like this.
In your 2nd Tablix create one more Column let's call it "PAC2ID_Calculated".
Now for this Column we will use lookup Expression =Lookup(Field!COMP_ID.value,
Field!COMP_ID.value,
Field!PAC2_ID,
"FirstDataset")
Now what will this return in your new Column, It will return PAC2_ID for COMP_ID from first dataset and your 2nd Tablix will be something like below
Once you get this, Group it based on PAC2_ID, you will get expected Result.
You can Hide COMP_ID column.

Display fixed number of rows on a tablix in SQL Server Reporting Services

I have a report made in SQL Server Report Builder and I would like to show a fixed number of row per table, not per page.
I found out this expression =CEILING(RowNumber(Nothing)/25) and probe it on the row group, bit did not work.
In the image above, I want to fixed the number of rows where the <> is going to be populated with database data.
How can make this?
In the Group properties add this as a Group on expression:
=CInt(Ceiling(RowNumber(nothing)/25)). Let me know if this works for you :)

How can I create a column of running values?

I have been creating reports to get use to the tools available etc.
I have come across an issue where I cannot get a column of running values to appear correctly.
I have circled the column where I want the running values to be displayed based on the values in "Min Heads" column.
I have tried this expression:
=RunningValue(Fields!DefaultValue.Value, Sum, "Tablix")
Where Tablix is the Matrix, this calculated the running values for each row. I have tried changing the scope to the row's group and dataset but haven't had any luck.
I would really appreciate it if someone could tell me what I am doing wrong and could tell me how to create the expression for the results I require.
Try setting the scope of the function to the name of the Min Heads column. So it would be something like this:
=RunningValue(Fields!DefaultValue.Value, Sum, "Min_Heads")
I think that the scopes you have tried are too wide, or simply not valid for this.

Customize the last three rows of a Tablix in SSRS

I have a table which is getting data from a query. Because I am not doing any calculation in SSRS, but instead in SQL and only pulling the data, I am having hard time figuring out how to customize the style for the last three rows.
Here is the design view:
Here is the preview:
Now as you can see the last three rows are either SUM or AVG of the above numbers. How can I make it so that the table displays a different background color for the bottom three rows?
You will need to add an expression for the text box format for the three rows that says something like:
=IIF(Fields![ARRIVED_DATE].Value="WEEKLY TOTAL","Grey",IIF(Fields![ARRIVED_DATE].Value="Prior Week","Red",IIF(Fields![ARRIVED_DATE].Value="12 WEEK AVERAGE","Green","Transparent")))
If i understand your point correctly this would be the solution =iif(total number of records(int)=rownumber(nothing), "Color1",iif(total number of records(int)-1=rownumber(nothing),"Color2",iif(total number of records(int)-2=rownumber(nothing),"Color3",""))) use this expression in Background color of row properties.

How to specify an order for the columns in a matrix?

I'm working on a SQL Reporting Services report (in VS.Net 2005) which displays a count of different data in a matrix. The columns have a count on the amount of customers in a certain set. So I have several columns like these: "1 employer", "2-9 employers", "10-19 employers" and so on.
The problem I have is that SQL Reporting Services sorts the columns in the matrix alphabetically. So I end up having the "10-19" column after the "1 employer" column but before the "2-9".
Is there any way to fix this?
Or maybe a trick to change the labels of the columns to that they sort right?
Thanks.
This can also be done by adding a new column to the query for the sort order. Then right click the column group from the matrix and select group properties. On the left hand side select sorting. From here you can specify another column to sort by instead of the column header. No custom formula needed.
We do a lot of SSRS Reports and this was always an issue with mdx. Here is one way we do it:
Set Sorting in the Grouping and Sorting Properties to sort by this expression:
=iif(Fields!DataSetField.Value = "ColumnName", "zzz", Fields!DataSetField.Value)
Where "zzz" could be a number or whatever you need it to be to help the sort and then select Direction as either Ascending or Descending base on this expression.
This may be a bit convoluted, but we had a similar problem and no means to change the SQL.
What we did was create a calculated field in the dataset that returns a number for each column and sorted the group on that number.
I had a similar problem but did not find a solution using a matrix in time - so I used a table - and put the needed logic of the matrix in my SQL-statements.
It's not the best thing to do but it works - it's fast enough and it don't takes that long to write.
I went into MATRIX --> PROPERTIES --> GROUPS.
Then, I "moved" the GROUP I wanted it to sort by UP in the list.
I went to PREVIEW, and it worked perfectly.
It even kept my column order the same.
Go to Edit Group - Sorting - Change the direction to descending for the expression.
For distinct numeric order of a Tablix use following line of code in expression.
=RunningValue(CountDistinct("YourTableName"),Count,"YourTableName")
Simply Go to tablix/Matrix Column Group and Right Click on the Group Properties then go Sorting and Delete the auto added record from Sorting.. Now your sorting will based on the Data you have added in Data set.