MY database have values like
3302540.8200
748712.9600
584879.2400
20787.5300
1338075.0000
I need the above values like below in my SSRS reports
3,302,540.82
748,712.96
584,879.24
20,787.53
1,338,075
I tried custom format for number on my text box #,0.######## but while exporting it in excel it is showing the value 1 as 1. (dot is not desirable)
help me with this.
TIA
Using the following as the datasource:
SELECT 3302540.8200 Number UNION
SELECT 748712.9600 UNION
SELECT 584879.2400 UNION
SELECT 20787.5300 UNION
SELECT 1338075.0000 UNION
SELECT 1000 UNION
SELECT 10123.20
You could use the following expression in your output table/Textbox:
=Format(Fields!Number.Value,"#,#.##")
Excel Output:
1,000
10,123.2
20,787.53
584,879.24
748,712.96
1,338,075
3,302,540.82
in your designed report in SSRS ,
type below in format section of your textBox
#,0;(#,0)
it works exactly as what u want
Related
I am calculating percentage and formatting the value as "0.0". That give me values like 3.7%, 4.1% etc. But when it's 1.0% I want to show as 1% only, how to remove decimal when the there is a whole value?
Thank you.
I am assuming your database values are in decimal format so that 0.01 represents 1%.
If this is not the case, let me know and I will modify the answer.
I created some test data with
SELECT 0.09 as pc
UNION SELECT 0.091
UNION SELECT 0.099
UNION SELECT 0.01
UNION SELECT 0.011
UNION SELECT 0.012
UNION SELECT 0.019
UNION SELECT 0.020
UNION SELECT 0.021
I then added a table to show the raw value plus various other formats.
Finally I added a 4th column that formats the value based on if it is a 'whole percent' or not.
I set the Format property of the textbox to the following expression.
=IIF(
Fields!pc.Value * 100 = CINT(Fields!pc.Value*100)
, "p0"
, "p1"
)
This basically checks if the value when multiplied by 100 is an integer, if it is then we apply p0 as the format code, if not we apply p1 as the format code.
The end result is as follows.
Note: We have only changed the format property of the textbox, not the value expression.
As you can see in the design below, each column's value expression is identical ([pc]), it is only the format property of each textbox that is different. To show the properties panel click on the textbox and then hit F4 in Visual Studio. If you are using Report Builder then I'm not sure if F4 works, but there is a menu option to show the properties panel somewhere.
Finally, you will obviously need to replace the field pc from my example with the actual field name in your report.
How about you wrap an iff statement around your formating?
Something along the lines of
=iif(round(Fields!num.Value) = Fields!num.Value,format(Fields!num.Value,"0%"),format(Fields!num.Value,"0.00%"))
This evaluates the output and if it is 1.0% then it makes it 1% else formats the rest of the value as required
I have a report that uses a simple bit of SQL
SELECT
[User Name]
,[Activity]
,(cast(LTRIM(DATEDIFF(SECOND, 0, left(cast(([Activity End Time]-[Activity Start Time])as time),8)))as int)) as [seconds difference]
FROM [iPR].[dbo].[TimeRecordingStatus]
where [Activity Start Time] between #StartDate AND #EndDate
This produces a matrix report that looks like this. I have used "Name" as the group name grouping on [User_Name].
I am trying to enumerate the rows in the "Name" group so that I can alternate colours to make it a bit easier to read. The expression I used in the Rownumber column is
=rownumber("Name")
I am expecting to see an ordered list from 1 to x but instead I get this. Which I can't even begin to parse why it would be in this order? Why 7 then 14 then 7? Any ideas what I'm doing wrong? The group has no filters just Group on [User_Name] and Sort By [User_Name] a to z.
You cannot use RowNumber as this looks at the dataset rather than what is displayed. What you actually need to do is get the number of unique ItemID's on or before each group.
=RunningValue(Fields!ItemId.Value,CountDistinct, "DataSet1")
Here is one of my example
docs for ref https://learn.microsoft.com/en-us/sql/reporting-services/report-design/report-builder-functions-runningvalue-function?view=sql-server-2017
I have a quick question regarding my SSRS report.
I currently have a report where I show a list of customers and their balances, sorted from A-Z.
However, there are a 4 customers that I would like to show one after another,
For example,
Adam
Alex
Dean
Brian* <-- I would like Brian and Fernando to be as shown, one after another, while the rest of the list still maintains A-Z
Fernando*
Leonard
Mark
Is this possible? Any input is appreciated!
Thank you
I Ran into similar problem in the past. I was able to overcome it be sorting the data in SQL using case statement before using it as a dataset in SSRS. See example bellow.
;WITH Sort AS
(
SELECT 'Aiden' AS CustomerName UNION
SELECT 'Jackson'UNION
SELECT 'Ethan'UNION
SELECT 'Liam'UNION
SELECT 'Mason'UNION
SELECT 'Noah'UNION
SELECT 'Lucas 'UNION
SELECT 'Jacob 'UNION
SELECT 'Sophia 'UNION
SELECT 'Emma 'UNION
SELECT 'Olivia 'UNION
SELECT 'Isabella 'UNION
SELECT 'Ava 'UNION
SELECT 'Lily 'UNION
SELECT 'Zoe 'UNION
SELECT 'Chloe 'UNION
------------------
SELECT 'Fernando' UNION
SELECT 'Leonard'UNION
SELECT 'Mark'
)
SELECT
CASE WHEN CustomerName = 'Fernando' THEN 1
WHEN CustomerName = 'Leonard' THEN 2
WHEN CustomerName = 'Mark' THEN 3
Else 4 END AS Sort,
CustomerName
FROM Sort
ORDER BY Sort,CustomerName
The proper way to get your expected should be mapping each customer to a corresponding group:
Group Name
Group1 Adam
Group2 Alex
Group3 Dean
Group4 Brian
Group4 Fernando
Group5 Mark
Then in your tablix you can create a group, it will show names in the same group one each other. Also you can get only one balance total by use something like this:
=SUM(Fields!Balance.Value,"Group")
However if you don't want to create a group, you can hardcode the names in a conditional sorting expression:
In your Tablix Properties / Sorting tab add a new soting expression and use:
=Switch(Fields!Name.Value="Brian","Brian1",
Fields!Name.Value="Fernando","Brian2",
true, Fields!Name.Value
)
You will get this:
Let me know if this helps.
I have for example a query with return something as it
route value
1 3
2 2
3 4
4 5
5 1
then I need to put in 2 textbox the max and the min route so in sql this would be
select top 1 route from table where value=(select max(value) from table)
I add a image done in excel, how this would be.
I believe this is so easy but I dont have idea how to get it.
I got using expression, this was extactly expression
="Route "+
Convert.ToString (
Lookup(max(fields!value.Value),fields!value.Value ,fields!route.Value,"mydataset")
)
changing max for min, for the other...
thanks everyone.
I believe the query you're looking for would be:
With Min_Max_CTE as (
Select MIN(value) as Min_Value
, MAX(value) as Max_Value
From Table
)
Select Top 1 'Min' as Type
, T.route
, T.value
From Table T
Inner Join Min_Max_CTE CTE
on T.value = CTE.Min_Value
Union All
Select Top 1 'Max' as Type
, T.route
, T.value
From Table T
Inner Join Min_Max_CTE CTE
on T.value = CTE.Max_Value
Order by Type desc --This will put the Min Route first followed by the Max Route
Then, put that query into a dataset, and then create a tablix and use the Type, route, and value fields to return the minimum route and the maximum route. It should end up being set up just like your excel section with the min and max routes above.
You can do this SSRS by using a couple of separate tables. Your example data:
And two tables in the Designer:
Since the tables only have header rows, only the first row in the table will be displayed.
To make sure we get the MAX and MIN values in the two tables, each table needs to order its Dataset appropriately, i.e. by Value by descending and ascending respectively.
MAX table:
MIN table:
Which gives your expected result:
I need to query in MS Access the difference in value of a column to 8 and only if it is greater than 8.
So if I have a column of numbers 1-10, I want to query the sum of all the value's differences from 8. So the result of the query for the below column would be 3. (9-8)+(10-8)
SELECT Sum(([time1]-8)+([time2]-8)+([time3]-8)+([time4]-8)+([time5]-8)+([time6]-8)+([time7]-8)+([time8]-8)+([time9]-8)+([time10]-8)+([time11]-8)+([time12]-8)+([time13]-8)+([time14]-8)+([time15]-8)+([time16]-8)+([time17]-8)+([time18]-8)+([time19]-8)+([time20]-8)+([time21]-8)+([time22]-8)) AS Total
FROM tblTimeTracking
WHERE (((Month(([Day])))=Month(Now()))) AND ([time1]>8 AND[time2]>8 AND[time3]>8 AND[time4]>8 AND[time5]>8 AND[time6]>8 AND[time7]>8 AND[time8]>8 AND[time9]>8 AND[time10]>8 AND[time11]>8 AND[time12]>8 AND[time13]>8 AND[time14]>8 AND[time15]>8 AND[time16]>8 AND[time17]>8 AND[time18]>8 AND[time19]>8 AND[time20]>8 AND[time21]>8 AND[time22]) ;
Thanks,
How about:
SELECT Sum([Value]-8) As SumOfVal
FROM table
WHERE [Value]>8
Edit re complete change in original question.
It is not clear what you want
SELECT Sum(([time1]-8)+([time2]-8) ...
WHERE [time1]>8 And Time2>8 ...
Time1>8 will exclude nulls, but if that is not what you are doing, you will need to consider:
Nz([time1],0) + ...
Edit re comments
Something like:
SELECT Sum(times) FROM
(SELECT IIf(Time1>8,Time1-8,Time1) As times FROM Table
UNION ALL
SELECT IIf(Time2>8,Time2-8,Time2) As times FROM Table) As b
As b is an alias: Access SQL
UNION / UNION ALL: View a unified result from multiple queries with a union query