SSRS Matrix Variance Column - Report Running Slowly - matrix

I am creating an SSRS Report based on a Stored Procedure; the procedure calls in the last six months of data based on the month the user enters into a parameter (ex. 201604). Currently I have this data going into a matrix, and along with those six months the report needs to have a variance column for the latest vs. directly prior month (ex. 201604 vs. 201603)
Right now I have a formula that works using a column that I created within the stored procedure to designate whether the month a row is in is CURRENT, PRIOR, or NONE if it is not being used in the calculation.
=SUM(IIF(Fields!VarHelper.Value = "CURRENT",1,0) * Fields!stock_value.Value
-
IIF(Fields!VarHelper.Value = "PRIOR",1,0) * Fields!stock_value.Value)
I am using this formula in three areas/cells on the report, and for some reason it is causing the report to run very slowly (around 45 seconds to run). Without these variance formulas in the report it runs almost instantaneously.
Would someone be able to either a).suggest a better method of calculating the variance between the latest two months in a matrix, or b).be able to at least shed some light on why this may be impacting report performance?
Thank you in advance!

Try to report the calculations on the query.
Two ways possible : if you made a sql query : make it in the select.
Or, add calculted field in the dataset.
And make sum on these fields.
May be you will win time : because the database server will make the job instead of the report server.

Related

How to create a DAX cross-sectional measure?

I don't know if I even worded the question correctly, but I'm trying to create a measure that depends on what is showing in the pivot table (using PowerPivot). In the image I posted, "DealMonth" is an expression in the PowerQuery table itself that simply takes the start date of the employee and subtracts it from the month a deal was closed in. That will show how long it took for that salesperson to close the deal. "TenureMonths" is also an expression in the PowerQuery table that calculates the tenure of the person. The values populating this screenshot are coming from a total headcount measure created. What I'm trying to do is create a separate measure that will show when the "TenureMonths" is less than the "DealMonth." So if the TenureMonths is 5, then after DealMonth of 5, the value would be 0. Is this possible?
Screenshot
I should add the following information.
"DealMonth" - Comes from the FactData table
"TenureMonths" - Comes from the DimSalesStart table
These two tables are joined by name. I feel like I'm so close because I can see what I want. The second image below is a copy/paste of the pivot table result but with my edits to show what I'd want to have shown. Basically, if(TenureMonths >= DealMonth,1,0). The trouble seems to be that since they're in two different tables, I can't make it work. The rows in the fact table are transactions, but the rows in the dim table are just the people with their start and end dates.
Desired Result
This is possible with some IF([measure1]<[measure2],blank(),[measure1]), however without seeing more of the data it will be hard to guide you specifically.
However you need to create two separate measures, one for TenureMonths and one for DealMonth, depending on the data this can be done with an aggregator forumla such as sum, min, max, etc (depends if there will be more than one value).
Then reference those two measures in the formula pattern I mentioned above, and that should give you want you want.
I figured out a solution. I added a dimension table for DealMonth itself and joined to my fact table. That allowed me to do the formulas that I needed.

Sorting time stamp values that get constantly updated via google forms

I have a google sheet that gets filled via a google form.
Time stamps are created every time a bar code (work order number) is scanned.
The work order number is in the first column.
The 4 unique time stamp fields below are populated in the 2nd column from the google form.
Setup start
Setup finish
Production start
Production finish
The time stamp is created in the 3rd column.
I am trying to do conditional formatting
where the total setup time and production time are calculated but they are tied to their respective work order number.
time stamp functionality
The difficulty is that the timestamp values all fall into one vertical column.
I don't want a mix up of timestamp values with different work order numbers.
The work order numbers along with the 4 unique time stamp values may be input at various times so the formula can't be order specific.
Is there a way to do this? Thanks!
Below is an example link of the spreadsheet I have:
https://drive.google.com/open?id=1YA86jGq_jMsx-wKe19TnZZyf9F4aW6_kUIbrz8hkLJI
Make a pivot table of the data from the form, then use simple formulas adjacent to the new pivot to get the results you are trying to get. Example Image

SSRS hidden columns expression consuming time while rednering

I am converting one crystal report to SSRS In which There are multiple group header having expression like
IIF(Fields!MainGroupOrder.Value = 2 And Fields!DaysOrHours.Value =
"Hours",IIF(Sum(Fields!Count_01.Value) = 0, 0,
Sum(Fields!Jan_CountTurnTime.Value)/Sum(Fields!Count_01.Value)/60),IIF(Sum(Fields!Count_01.Value)
= 0, 0, Sum(Fields!Jan_CountTurnTime.Value)/Sum(Fields!Count_01.Value))/60/9)
There are 12 such statements in each row with 5 rows
This row with 12 columns has visibility condition at row level
When I am viewing report after removing these expression, Report is taking 37 seconds to render
With same parameter when I am rendering report with these expression It is taking 1 minutes and 20 seconds (these expressions are not visible with given parameters)
I read somewhere that SSRS after 2005 does not calculate hidden column till its not used in any other visible condition
Then why time is increasing on inclusion of these expression even though these are not visible and also not used in any visible condition
Can you explain why and it would be great if you can help me in decreasing the time this report is taking due to these expression which are not visible
Thanks
In SSRS, every expression takes time to evaluate. Even invisible objects complete all their calculations. You can easily test this by making everything invisible, it doesn't save any time.
Here are some general tips to make SSRS reports faster:
Optimize the original query.
Cache the report beforehand.
Do more of the calculations in the SQL as opposed to in the report.
Use a stored procedure instead of plain SQL.
Use parameters to filter the query to just the data you need as opposed to filtering it in the report afterwards.
Use a calculated field to consolidate logic that is used in multiple places in the report. This way, the calculation is only done once per row.

SSRS 2012 total of a percentage measure

I have a percentage measure calculated in SSAS tabular and its correct.
But when i use it in a report i face the following problem (in all percentage measures).
the values under male and female (which are subgroup of saudi and non-saudi) are correct but if you look at the total under "Both sexes" it is incorrect,because it shows summation of male and female percentage, where the right thing is it shows the percentage of the saudi or non-saudi.
If i calculate the measure in SSRS in the expression fields i get it right as follows
But i want to use the measure to show the right values.
So.. can anyone help me with this i have serious issues in later reports and i just cant simply recalculate the SSAS measures in SSRS using expressions.
Note: dont mind the decimal places differences between the two pics.
Thank you.
You can change your MDX query in SSRS to return the subtotal rows then change your Textbox formulas in the body of the Report to say =Aggregate instead of =Sum. This process is described more here by Stacia. You can use manual MDX queries. Don't miss the comment at the bottom:
Romuald Coutaud March 17, 2011 at 7:52 pm Hi Stacia,
In fact, it works in query mode too in 2008R2. But, I have to admit
that the way that RS and AS work together when you want to use
aggregate function is very difficult to perfectly understand and I
have struggle very long time to make one sample report running in this
way. In query mode you need to write MDX by referencing each level of
the hierarchies from the top one to the deepest one want to display in
your report, even you don’t need to use all these ones. As an example
you have to put Year, Quarter and Month to be sure to display Month
and be able to use aggregate function.
Basically in your report =Aggregate will try to retrieve a row where Nationality is not null and Gender is null. If you get stuck please write back with the list of each field used in each group in SSRS and a screenshot of the MDX query designer.

How can I get the values in the Matrix on my SSRS report to repeat?

I know there must be a simple answer to this, but I can't find it.
I have added a couple of textboxes to a Matrix in a BIDS/SSRS report. I've given these textboxes values such as:
=Fields!WEEK1USAGE.Value
It works (after a fashion); when I run the report (either on the Preview tab, or on the Report Server site) I see the first corresponding data value on the report - but only one.
I would think that once a value has been assigned via expressions such as "=Fields!WEEK1USAGE.Value", each value would display (rows would automatically be added).
There must be some property on the Matrix or the textbox that specified this, but I can't see what it might be.
Here is how my report looks (very minimalistic, so far) in the Layout pane:
...and after running, on the Preview tab:
Obviously, I want the report to display as many rows as necessary, not just one. The textboxes do have a "RepeatWith" property, but there description doesn't sound interesting/useful/promising.
I don't see any property on the Matrix control that looks right, either.
I thought maybe the designer was only showing one row of values, and ran the report on the server, too, but there also it just shows the two values.
So what do I need to do to get all the data for a provided field?
Matrices are for display of grouped data and summary information, usually in a horizontally expanding pivot table type of format. Is a matrix really what you are after? Looking at your expression you have =Fields!Week1Usage.Value but in a matrix what I expect to see would be at least =Sum(Fields!Week1Usage.Value) or even better just =Sum(Fields!Usage.Value). Then you would have ProactDescription as your row group and the week as your column group and it would all just work out everything for you, grouping and summing by Proact vertically and expanding the weeks out horizontally.
What seems to be happening is that you have no grouping on rows or columns and no aggregation so it is falling back to the default display which is effectively the First function - it displays the first row of data and as far as the matrix is concerned it has done its job because there is no grouping.
Without knowing your problem or data, I'll make up a scenario that might be what you are doing and discuss how the matrix does the heavy lifting to solve that problem. Let's say you have usage data for multiple Proacts. Each time one is used you record the usage amount and the date and time it is used. It could be used multiple times per day but certainly multiple times in a week. So you might be able to get the times each Proact is used from a table like so:
SELECT ProactDescription, TimeUsed, Usage
FROM ProactUsage
ORDER BY ProactDescription, TimeUsed
In your report you want to show the total weekly usage for each Proact over multiple weeks. Something like this:
Proact Week1 Week2 Week3 ...
Description Usage Usage Usage ...
--------------------------------------------
Anise, Fennel 1 CT 20.00 22.50 16.35 ...
St John's Wort 15.20 33.90 28.25 ...
...
and so on. Using a dataset based on the SQL above we create a matrix and in the row group properties we group on =Fields!ProactDescription.Value and in the column group properties we group on a week expression like =DateDiff(DateInterval.Week, Fields!TimeUsed.Value, Today) and then in the intersection of the row and column we put =Sum(Fields!Usage.Value). To display the header of the column nicely put an expression like
="Week " & DateDiff(DateInterval.Week, Fields!TimeUsed.Value, Today)
The matrix automatically does all the summing by week and product and expands the weeks horizontally for as many as you are reporting. For bonus points you can also put totaling at the end of the columns and the rows to show the total use of that Proact for the period (row total) and total use of all Proacts in that week (column total).

Resources