SSRS or SQL - DateDIFF on the same column with certain criteria - sql-server

I have a report I created in SSRS. I have it grouped by a column. The Column it is grouped by there are description, details and a date for each.
I want to try and find a datediff between two descriptions for the group but I can't seem to get it right.
I tried to do ::
=DateDiff(dateinterval.Minute,(Fields!date.Value=(Fields!description.Value="description1")),(Fields!date.Value=(Fields!description.Value="description2")))
but it errors out. any idea ? I can supply the code or screenshot if it doesn't make sense.

Try this:
=DateDiff(DateInterval.Minute
,lookup("description1",Fields!description.Value,Fields!date.Value,"DataSet1")
,lookup("description2",Fields!description.Value,Fields!date.Value,"DataSet1"))
Let me know if this was helpful.

Related

number of months between two dates in salesforce

I have a report in Salesforce that contains an Estimated Start Date and Estimated End Date - see below example:
What I want to do is create a formula column that will allow me to show how many months are between those dates.
I can do this easily in excel using DATEDIF but cannot replicate that in the salesforce report itself - see below example of desired result using DATEDIF in excel:
Can anyone advise on the easiest way to achieve this result as a formula column in Salesforce?
Many thanks
I did this by creating a field with the below formula
((CloseDate - Estimated_Start_Date__c) /(365/12))

Datastudio: Blended Data: Date aggregation not working

I have a blended data source, that connects two filtered Google Analytics metrics. In there I have a calculated chart field, that gives me the ratio between these two filtered metrics. Now I'm trying to change the date aggregation to year-month, but there seems to be a problem.
This is with date auto, which is perfect:
However this is what happens with Year Month aggregation:
There should be only a line per month left, but somehow the aggregation is not working.
Do you have any idea on how to fix this? I've setup my blended data source at least 10 times trying to use the date on one source or as a key, but none worked.
Cheers
Andreas
I didn't find a fix either. Worked around it by making a custom field with the function MONTH(date) and using that. Works like a charm
Your solution did the job perfectly. Thank you, Joppe. I am quoting your workaround as an answer to bring more visibility to it.
Credit: Joppe De Cuyper (comment in the question)
Best solution here :
https://support.google.com/looker-studio/thread/96504295?hl=en
I have found others with a similar issue
https://support.google.com/datastudio/thread/65220021?hl=en
The workaround I guess is to maybe have dedicated column that represents date month in your source data. So 01-01-2021 for all Jan 2021, etc. As long as they are the same it should work I think.
WORKAROUND
You can use the following Formula and add a calculated field to your source table:
DATE(YEAR(your_date_column),MONTH(your_date_column),1)
Last edited Feb 3, 2021

SSAS cube and getting data with MDX for SSRS report

I'm new to OLAP cubes. Can you directed in the right direction with small example.
Let's say I have table "transactions" with 3 columns: transaction_id (int), date (datetime), amount (decimal(16,2)).
I want to create a cube and then get data with MDX query for SSRS report.
I want report to show something like:
Ok. I know i can have fact table with amount and date dimention (date->month->year).
Can you explain what to do in order to get this result (including how to write MDX query). Thanks.
Can someone explain why I get amount of full 201504 and 201606 months even if I specified exact range with days?
SELECT
[Measures].[Amount] ON COLUMNS
,[Dim_Date].[Hierarchy].[Month].MEMBERS ON ROWS
FROM
[DM]
WHERE
(
{[Dim_Date].[Date Int].&[20150414] : [Dim_Date].[Date Int].&[20160615]}
)
Something like below, change the query accordingly :)
SELECT
{ [Date].[EnglishMonthName].[EnglishMonthName]} ON COLUMNS,
{ [Date].[DateHierarchy].[Year].&[2015],
[Date].[DateHierarchy].[Year].&[2016] } ON ROWS
FROM [YourCubeName]
WHERE ([Measures].[amount])
So you want someone to show you how to create a multi-dimensional cube from scratch and report on it in a single answer...? Start here and work through the lessons

Ssrs reports Windows 2008

I'm fairly new to SQL and I have been issued my first report to build. I have written an SQL query to give me a set of results that I would like to publish in a report.
I have unioned about 20 small queries all containing the correct amount of columns. One column is a misc column with about 15 different descriptions in (this is what I want to count).
I have uploaded my data set and now want to be able to choose a cell in my report to bring back a certain description.
At the minute I'm using
=count(fields!misc.values)
and it's giving me the whole count, about 200.
I would like to know if there is any kind of "where clause" (filter) which I can use to state which description results I want to bring back.
You can use am expression to count the misc.value you need. It will work like a count using a where clause:
=Sum(iif(Fields!misc.Value ="Some description",1,0))
Example:
For count the FSMethod with MethodOne as value I used this expression:
=Sum(iif(Fields!FSMethod.Value ="MethodOne",1,0))
Note the expression sums by 1 if the FSMethod.Value is MethodOne.
For count the rows with FSMethod column with MethodTwo value.
=Sum(iif(Fields!FSMethod.Value ="MethodTwo",1,0))
Let me know if this can help you.

SQL Server query to Crystal Reports

I am trying to move reports that currently run in SQL Server to Crystal Reports.
Essentially the statement I want to reproduce is:
SELECT DATEPART(DD,DATE), COUNT(*)
WHERE FOO = 'BAR'
GROUP BY DATEPART(DD,DATE)
Count the occurrence of records that match a criteria, grouped by date.
I have used the Selection Expert to generate a equivalence relation (to evaluate the records) and would like to use the datepart function in a group by statement. I have gotten the GROUP BY selection expert to group by date - but it is the full timestamp (SS:HH:DD:MM) not by specific day i.e. March 1 2010.
I am sure there is a way to achieve what I want but have yet to find a tutorial explaining this scenario.
Any help you could lend would be appreciated
As with any other SDK/Language, there are many ways to do this. Here is the first one that I can think of:
Get the raw data into Crystal. (Sounds like you already did this)
In Crystal, make a new formula, call it "GroupByDate". In the formula editor, enter:
datepart("yyyy-mm-dd",{mytable.mydatefield})
Go into the Group Expert. Group your report by GroupByDate.
Make a new formula, call it "AddMe". In the formula editor, enter:
iif({mytable.foo="bar",1,0)
Drag & drop your AddMe formula into the details section. Right-click on it to Insert->Summary. Set your summary location as the group footer.
Preview your report and you should see the total counts in every group footer. To simplify the appearance of the report, you can also suppress the display of the detail and grouper header sections.
Again, there are many ways to do this. You can also get creative with a Running Total function. The Crystal Formula Editor has very useful help files. Use the Functions pane to select a function, press F1, and you'll get criteria, examples, etc.

Resources