i want to find last data in tableau .
i used this code, but it doesn’t satisfy the results i want.
[datatime]={FIXED:MAX([datatime])}
and results just this
this is my data table
and i want the result
You're missing some steps.
first of all you need to calculate the max date (Max Date) for each line and this something you can achieve twisting your Fixed formula, like this:
{ FIXED [line] : MAX([datetime])}
Then you need to create another calculated field (Check Max Date) to check this condition:
if [datetime] = [Max Date] then 'max' else 'other' end
Then you can use Check Max Date as a filter keeping just the 'max' values.
This is a quick example based on Sub-Categories from the Superstore sample dataset.
Related
I am trying to create a running balance column in Spotfire that's supposed to look like the picture attached below. In essence,I want to calculate the cumulative total of the "amount" column row by row, and that I want it to start from 0 as the date changes.
I have tried several OVER functions:
Sum([AMOUNT]) OVER AllPrevious([Date])
Sum([AMOUNT]) OVER Intersect([CURRENCY],AllPrevious([SETTLEDATE]))
Sum([AMOUNT]) OVER Intersect([Calculation Date],AllPrevious([SETTLEDATE]))
Any help is greatly appreciated.
You were very close with your first over statement. The problem is, when you use over (AllPrevious([Date])) and you don't have 1 row for each date, then you will skip rows. So, the last row of your data would only sum it over the rows where 6/1/2017 is in the Date column. Instead, we need to apply a RowID to your data set and then sum over it. This will ensure we sum over all previous rows.
Assuming your data set is in the order you want it to be in when you bring it into SpotFire, do the following:
Insert a calculated column RowID() and name it RowID
Use this calculation: Sum([amount]) over (Intersect([Date],AllPrevious([RowID])))
This will give you the running sum you are looking for.
#scsimon- I modified your custom expression slightly to include date as requested in the question.
Modified expression:
Sum([Amt]) over (intersect(Allprevious([rowID]),[Date]))
Final output table:
#LeoL - Hope this answers your question.
I've tried limiting data on monthly basis in spotfire and it's working fine.
Now I'm trying to do like getting the records from the current date to month start date.
For suppose if the current date is Sept 21, then i should get the records from Sept 21 to Sept-01(dynamically).
I have a property control to input the number of months.
The easiest way to do this is with Month and Year. For example, in your visualization:
Right Click > Properties > Data > Limit Data Using Expressions (Edit)
Then, use this expression:
Month([TheDate]) = Month(DateTimeNow()) and Year([TheDate]) = Year(DateTimeNow())
This will limit the data to only those rows with the current Year/Month combination in your data column. Just replace [TheDate] with whatever your date column name is.
In other places, you can wrap this in an IF statement if you'd like. It's redundant in this case, but sometimes helps with readability.
IF(Month([TheDate]) = Month(DateTimeNow()) and Year([TheDate]) = Year(DateTimeNow()),TRUE,FALSE)
#san - Adding to #scsimon answer. If you would like to precisely limit values between 1st of the current month to current date, you could add the below expression to 'Limit data using expression' section.
[Date]>=date(1&'-'&Month(DateTimeNow())&'-'&year(DateTimeNow())) and [Date]<=DateTimeNow()
I want to calculate the percentages using date fields in my SSRS report.
I have two date fields :
eg I have 3 columns in my matrix
monthly target,
monthly completed and
percentage
Due date field count 10
completed date count 5
percentage 50%
for example
=Sum(Fields!Completeddate.Value)/Sum(Fields!duedate.Value)*100
however, this will not work for date fields.
Can anyone help?
Thanks in advance
The most straight-forward way to do this would be to add this field to your stored procedure (since it represents a column in your matrix) instead of trying to calculate it in SSRS.
Your SQL statement may look like this:
SELECT #CompletedDate, #DueDate, CAST(DateDiff(day, GetDate(), #CompletedDate) AS FLOAT)/CAST(DateDiff(day, GetDate(), #DueDate) AS FLOAT) * 100 AS INT) AS [Percentage]
The exact implementation will depend on how exactly you're using this value, but the point is that you can use the DateDiff() function to determine how many days apart two dates are, and with that information, you can find a percent difference. Once you've calculated this, you can assign it to a matrix column like you would any other value.
I am working on a SSRS report that displays Date, Time and few other columns.
My SP returns just Date Column (which has time part in it) and a few other columns.
In the report I want to group by Date Part and show all details including the time (I used formatting option "T" to display only Time in Date column) in the details group.
For grouping on Date I used:
=FormatDateTime(Fields!TxDate.Value, DateFormat.ShortDate)
Which seems working. However if I try to sort on other columns it is not working. Any thoughts/suggestions on this?
It might be easier if you were to add an extra column into your dataset that was based on your original date+time column but containing just the date. Then you can use this to do a simple group on that column.
For example, if the dataset is based on a SQL query and your date+time column is called [Date], then add another column in the query as CONVERT(DATE, [Date]) AS DateOnly or something similar.
I have two dimension field say [Custom Date] which have data like 'September 2009' and [Custom Date With Formart] which have data like 'Sep-09'.
I am applying order function to arrange it as shown below.
Order(BottomCount(
{[CUBE].[Custom Date].[Custom Date].ALLMEMBERS}, 12),
[CUBE].[Custom Date].[Custom Date].[], DESC)
ON COLUMNS,
It arranges my dates as 'September 2009','October 2009'....,'January 2010','February 2010'.
Order(
{[CUBE].[Custom Date With Formart].[Custom Date With Formart].ALLMEMBERS},
[CUBE].[Custom Date].[Custom Date].[], DESC)
ON COLUMNS,
Output for above is like 'Jan-10','Feb-10',....,'Sep-09','Oct-09'.
What i want is to display [Custom Date With Formart] on axis and sort it using [Custom Date].
Let me know your comments.
Thanks to all of you. I resolved my issue by following this link.
I'm not sure to really understand your issue. Why do you need any specific ordering to get what seems to be
the natural ordering of a time dimension. In any case, it might be that you need to use the BDESC option instead of DESC (see documentation here).
You could try creating a string to sort on, and converting it to a date, if you can cope with VBA:
ORDER(whatever, CDate("01-" + [my dimension].currentMember.caption), BDESC)
That code may not run as it is, but what I'm trying to suggest is that you take the string of your member name "Sep 10" and turn it into a string with a full date in (first of the month), which can then be converted into a date, and used to sort on.