Add delta into tablix SSRS - reporting-services

This is type of my dataset:
| Date(dd/mm/yyyy) | Value |
|------------------|-------|
| 01.01.2018 | 50 |
| 01.01.2019 | 100 |
| 01.03.2019 | 200 |
| 01.05.2019 | 400 |
from this dataset i maked tablix:
| Date | 01.01.2018|01.01.2019 | 01.03.2019 | 01.05.2019 | Δ |
|-------|-----------|-----------|------------|------------|-------|
| Value |50 |100 | 200 | 400 |300 |
How to put into tablix change value(+300) between 2 dates: 01.05.2019 -01.01.2019?
I used construction with lookup function, but it doesn't work:
made dataset with 2 dates:01.05.2019 and 01.01.2019
=lookup(min(Fields!Date.Value,"dataset2"), Fields!Date.Value, Fields!Value.Value, "dataset1")

If you add a parent column group call for example colgrpYear and set the grouping expression to be something like:
=YEAR(Fields!Date.Value)
This will group by the year -- you can hide the column group header if you like.
Then set the calculation expression to ..
=Last(Fields!Value.Value, "colgrpYear") - First(Fields!Value.Value, "colgrpYear")
This will scope the expression within the just the year that the cell resides in.
Note The scope must be in double quotes and is case sensitive.

Related

Merge duplicate (row group) column cells

ID| Date1 | Date 2 |Total
-----------------------------------
1 | 15/02/2017 |02/02/2017 | 3 |
-----------------------------------
1 | 15/02/2017 |05/08/2017 | 3 |
-----------------------------------
1 | 15/02/2017 |12/12/2017 | 3 |
-----------------------------------
2 | 12/05/2017 |07/08/2017 | 2 |
-----------------------------------
2 | 12/05/2017 |10/08/2017 | 2 |
I have a table that is displaying data like above. I'm grouping that data on "ID" column. Values for Columns "Date1" & "Total" for a particular "ID" are the same but "Date2" value can be different in a given group.
How can i merge the cells across rows when the values are the same such that it displays like below?
ID| Date1 | Date 2 |Total
-----------------------------------
1 | 15/02/2017 |02/02/2017 | 3 |
--| |------------| |
1 | |05/08/2017 | |
--| |------------| |
1 | |12/12/2017 | |
---------------------------------|
2 | 12/05/2017 |07/08/2017 | 2 |
--| |------------| |
2 | |10/08/2017 | |
I did manage to find that "HideDuplicates" TextBox property, but while that will suppress the repetition of the cell values in adjacent rows it does not merge those duplicate cells down the column across rows
Its difficult to tell how the report is setup in terms of groups etc without seeing the design, but this is pretty simple to do from scratch.
Start with a simple table with just your detail rows, no grouping. Then right-click the detail row in the row group panel under the main report design area. Choose Add Group -> Parent Group
Choose your Date1 field in the group by drop down . Click OK and you're done.

export mysql table with data spread over multiple rows to csv

I have a mysql table which is filled with inputs from a webform on my website. The form has fields for last name, surname, email, phone, address, etc.... and when a user submits the form these data are stored in a mysql table in a rather strange way.
my table looks like this:
subission# | value | field | tstamp | and |many |more |columns
=====================================================================================
1 |john#server.com |email |1448898875 | | | |
1 |john |firstname|1448898875 | | | |
1 |doe |lastname |1448898875 | | | |
1 |london |city |1448898875 | | | |
2 |jane#aol.com |email |1448898870 | | | |
2 |jane |firstname|1448898870 | | | |
2 |doe |lastname |1448898870 | | | |
2 |new york |city |1448898870 | | | |
3 |tim #aol.com |email |1448838571 | | | |
3 |tim |firstname|1448838571 | | | |
3 |smith |lastname |1448838571 | | | |
3 |paris |city |1448838571 | | | |
I need to export these data to a csv file in order to import it to a newsletter script on some other server, but the server expects these data in a different format:
submission#,email,firstname,lastname,tstamp,.....
1,john#server.com,john,doe,london,1448898875,,,,
2,jane#aol.com,jane,doe,1448898870,,,,
The export as csv is not the problem, but how do I get all the data of one submission# into one row? Can anyone please point me into the right direction, how to accomplish this with SQL?
You can achieve the desired output, if you concatenate the field contents into a single field using concat() and group_concat() functions, where the values are separated by comma.
The only issue can be if for a particular submission any of the properies is missing. If that's the case, then you will need a helper table which lists all properies and you need to left join on that table. Since this is not the case for your sample data, I'm not providing the code for this scenario.
select concat(submission, ',', group_concat(`value` order by `field` asc), ',',tstamp)
from table group by submission, tstamp
If you need the field names in the 1st row, then create a separate query that conatenates the field names separated by commas and combine the 2 with union.

Grouping data in a SSRS report

In developing an SSRS 2008 R2 report, I'll like to show some data grouped by values, while merging others, I've run into a problem doing this on report builder.
| Parent Group |
|_______________________________________|
|Group A|Group B|Group C|Group D|Group E|
|_______|_______|_______|______|________|
| 5 | 2 | 1 | 1 | 5 |
| 4 | 2 | 4 | 2 | 2 |
| 1 | 3 | 1 | 3 | 2 |
Can I create a filter or grouping to combine Group C, D, E together while leaving A and B alone?
Like such,
| Parent Group |
|_____________________________|
|Group A |Group B|Other Groups|
|________|_______|____________|
| 5 | 2 | 7 |
| 4 | 2 | 8 |
| 1 | 3 | 6 |
There are two ways you can achieve this:
SQL query
Usually the best way to get the result you want is to let SQL do the heavy lifting:
SELECT GroupA, GroupB, (GroupC + GroupD + GroupE) AS OtherGroups
FROM MyTable
In the report
If you can't change your query result (for example, it is a stored procedure) then you can do the same thing in SSRS VB code.
Right-click the cell and choose Expression... and enter something like the following:
=Fields!GroupC.Value + Fields!GroupD.Value + Fields!GroupE.Value
and SUM in the same way:
=SUM(Fields!GroupC.Value) + SUM(Fields!GroupD.Value) + SUM(Fields!GroupE.Value)

SSRS Page break every 1000 rows on group

I have the following table of data from an MDX query that resembles the following:
Account | Location | Type | Person | Amount
ABC | XYZ | AA | Tom | 10
ABC | XYZ | AA | Dick | 20
ABC | XYZ | AA | Harry | 30
ABC | XYZ | BB | Jane | 50
ABC | XYZ | BB | Ash | 100
DEF | SDQ | ZA | Bob | 20
DEF | SDQ | ZA | Kate | 10
DEF | LAO | PA | Olivia | 200
DEF | LAO | PA | Hugh | 120
And I need to add the Amount column for each Account, Location, and Type. If I was using SQL I would perform a query on this data as follows:
Select Account, Location, Type, Sum(Amount) as SumAmmount
From Table
Group By Account, Location, Type
but due to the way we store the data I need to roll-up this data using SSRS. To do that I created a tablix, created a parent group (Which I have called "RollUp") of the default detail group which grouped on Account, Location, and Type and then deleted the detail group so when running the report I get:
Account | Location | Type | Amount
ABC | XYZ | AA | 60
ABC | XYZ | BB | 150
DEF | SDQ | ZA | 30
DEF | LAO | PA | 320
What I need to do now is create a page break so that when I export this SSRS report to excel there are only 1000 rows on each sheet, but I am having trouble writing the expression to split this every 1000 rows. Because I have removed the details group I cannot use the typical expression I would use to page break on a specific row of a dataset (e.g. Group Expression = Floor(RowNumber(NOTHING) / 1000) )
I have tried a few different things like writing some custom code and some running value expressions but haven't been able to figure it out yet.
I did figure out how to do this.
First I created the following custom code in the report definition:
Dim GroupingDummy = "GroupDummy"
Dim RowNumberToReturn = -1
Function PopulateRowNumber(GroupString As String) As Integer
If (GroupString <> GroupingDummy ) Then
GroupingDummy = GroupString
RowNumberToReturn = RowNumberToReturn + 1
End If
Return RowNumberToReturn
End Function
Keeping in mind the grouping I applied to the dataset used the fields Account, Location, and Type, I added a calculated field to my dataset with the name RowNumberCalc and the expression:
=Code.RowNumberToReturn(Fields!Account.Value + Fields!Location.Value + Fields!Type.Value)
Now I could easily create the group that would create a page break at 1000 rows with the expression :
=Floor(Fields!RowNumberCalc.Value / 1000)

SSAS MDX - Select from one dimension depending on two other dimensions

I have three dimensions, a [Transaction], [Trade Date] and [Report Date].
The [Transaction] is related to both, and I would like to define a function for a KPI in which I look for the following:
For each date where there exists a trade in as a transaction, check from this date and a range that goes 30 days back for transactions where the difference between [Trade Date] and [Report Date] is greater than 1.
I want to sum up the [Measure].[N of Transactions] in this range, for each trader on each date.
I've tried the following:
WITH
SET [Filtered] AS FILTER(NONEMPTY({[Trade Date].[Calendar].CurrentMember.lag(30):[Trade Date].[Calendar].CurrentMember}),
DateDiff("d",
CDate([Report Date].[Calendar].CurrentMember.MemberValue),
CDate([Trade Date].[Calendar].CurrentMember.Lag(1).MemberValue)
) > 1
)
MEMBER [Measures].[x] AS SUM([Filtered].CURRENTMEMBER, [Measures].[N of Transactions])
SELECT [Measures].[x] on 0,
[Transaction].[Trader].&[some_id_here] on 1
FROM [Relevant]
WHERE [Trade Date].[Calendar].[2014-02-16]
But this obviously doesn't work.
+----------------+
|factTransaction |
| |
+----+ +----+
+-------------+ | | | | +-------------+
|dimTradeDate | | | | | |dimReportDate|
| | | | | | | |
| +----- | | +----+ |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+-------------+ +----------------+ +-------------+
 
Above is the structure in the designer. To sum it up, how do I write an MDX query that looks at each date, backtracks 30 days and creates a range. From this, look at all transactions and return the sum of the measure [Measures].[N of Transactions] for that range and [Transaction].[Trader]?
I had a somehow similar question today, and got answered. See if it somehow helps you:
Mdx Using a member property as an argument for a strtomember
Might be the same issue... the set condition is evaluated before the rows definition, so, when you specify currentmember on the Set, it doesn't get the desired argument. I've solved my issue putting the set inside the member definition, and, as I had seen your question before, thought that it might be a similar case ...
CF.