How can I get a Telerik Reporting graph to sort the x-axis by a date and format that date? - telerik

I have a Telerik report with a graph. The graph's x-axis is a series of dates. Our client would like those dates in order from oldest to most recent. They also want the dates formatted to not include the time portion of the date. I've tried for the past day to get this to work and can't figure it out. Can someone explain how to do this?
I started out with a graph based on this query:
SELECT AnalysisNumber
, convert(varchar, DateSampled, 01) as DateSampled
, ViscosityAt100C
FROM tblSample
ORDER BY a.DateSampled ASC
The results look correct with the dates in order from oldest to most recent:
but a graph is produced where the dates were not in order:
I can't begin to include all the setting for the graph, but here is what I think is the relevant part. Let me know if there's something else I can show you.
Notice the sorting is by DateSampled which is now, of course, text not a date.
If I remove that sorting (to try to preserve the original sorting from the SQL query), the graph no longer works:
So I tried to use a date instead of text. The query is now this:
SELECT AnalysisNumber
, DateSampled
, ViscosityAt100C
FROM tblSample
ORDER BY a.DateSampled ASC
...the output looks the same:
and the graph looks like this:
The dates are sorted the way I want, but all the dates have a time element that I don't want because it's irrelevant and it takes up too much space.
I tried changing the type in SQL:
Cast(DateSampled as Date) as DateSampled
but it still showed the time in the graph.
I tried formatting it using the properties for the x-axis:
but it did not change the formats of the date. In fact, changing to any of the formats in that property did not change anything.
Lastly I tried to include both a string and date in my query:
SELECT AnalysisNumber
, convert(date, DateSampled) as DateSampledText
, DateSampled
, ViscosityAt100C
FROM tblSample
ORDER BY a.DateSampled ASC
and using the DateSampledText to group by and the DateSampled to sort by:
it just ruins my graph again:
I tried adding the text version to sorting and other variations, but never got the graph back to where it was showing data.
Sorting and formatting a graph doesn't sounds like it should be difficult. This was supposed to be one of the final changes before going into production and I've already spent so much time on this. Can someone tell me how to make this work? Thank you!

I believe you need to change the scale of your graph. I think by default it is Category Scale, but when using dates, you would need to change it to DateTime scale.
In your graph properties, where you set the Format of the X-Axis, there should be a property called Scale. Try setting it to DateTime.
Keith

The reason you can't format the dates is because the graph is treating them as strings.
You need to change the x axis to be of type DateTime Scale instead of Category Scale. Category scale is the default and is more appropriate for when you are graphing the number of Apples, Oranges, and Pears, for example.
In the standalone report designer the setting is under Presentation Category > Coordinate Systems > cartesiancoordinatesystem1 > X Axis > Scale
..
In addition to changing the scale type, because the scale expression is now not just a string, you also need to set the X value on your line series.
This setting is under Presentation Category > Series > lineseries1 > X
For some unknown reason the setting should not be "=Fields.DateSampledText", but "DateSampledText". The documentation is irritating bare of details like this.

Related

DAX ignore row context in measure. Calculate for a defined set of dates and show the value for all dates in visual

I am trying to create a measure which calculates the average daily revenue per customer, but only using days in a 6 months period prior to a specific date (where some type of conversion happens).
This specific date can be different for each customer.
The intention is to use the measure as a baseline for indexing daily average in the days/months/years after said conversion date.
If I put my current version of the measure in a card it works just fine (circled in green). But I will eventually have to visualize this over time as well. Thus I need the value to stay the same regardless of the row/date context in a table or timeline (circled in orange).
I suspect I need to use one of the ALL/ALLSELECTED/ALLEXCEPT filter modifiers but I can't really get anything to work.
The measure looks like this for now:
Average daily rev before conversion = CALCULATE (
AVERAGEX(
VALUES('Date'[Date]),
[HI & Acc Rev]
),
FILTER('poc vFact_SalesLine','poc vFact_SalesLine'[OrderDate_ID] IN DATESINPERIOD('Date'[Date],FIRSTNONBLANK('poc vDim_Customer'[DSE first conversion date],1),-6,MONTH)))
I've tried adding REMOVEFILTERS('Date'[Date]) just before the filtering of order dates, but that doesn't work. Gives me the exact same values as shown below.
All help is very welcome? Is my approach all wrong?

How can I sort the date in the X axis properly on a Bar Chart in Kibana?

I'm trying to order the date ascendantly in the X axis of the chart. And I've set it up that way here:
However, this happens:
Is there a way to work around this? 25 January should be the last bar. I've tried changing data formats to see if it would order properly but with no success.
You haven't specified how you are generating this graph, but it looks like you've done a Terms aggregation on the date field. The order by you are showing is then for the terms count. If you look right above that, it probably says order by: Metric count. What you want it to say is Order by: term.
In any event, in general, you don't want to aggregate by date like that. Instead choose a Date Histogram aggregation. That will allow the time filter/aggregation bucket size to be changed.

Chart - Date Order - Google Data Studio

I'm doind a chart of warehouse income and outcome but X-Axis is not ordering the date correctly
Does anyone know how to fix it?
Try setting the Sort parameter to you date dimension and use Ascending option for it.
Should look like this:
Here you can find detailed docs for all the chart types used in GDS.

Total less available = Remaining Formula in Power Query

I have a bunch of statistical data that I have chopped up and pieced together in power query. In looks like there is category missing from the Database. To fill in the gaps I am trying to take the grand totals which are correct (red), subtract from that what I know to be correct, with the remaining numbers giving me my answer (orange).
The correct data starts with I1, I2, I3, I4, so possibly a grand total of these, by state.
At the moment this is filled by the following formula in excel;
=E53-SUMIFS($E$5:$E$44,$B$5:$B$44,B45,$C$5:$C$44,C45,$D$5:$D$44,D45)
Any help with how the heck I can do this in power query. I realise I cant use the same formula but any ideas would be much appreciated. I can change the text in red to total if that helps in some way?
Thanks
Here's one potential way. If you start with your spreadsheet set up similar to this:
I only used a subset of your StateIDs from your example and generated my own Values for this example. And the figures in the Available column would be from your red section.
Then add the table from the spreadsheet to Power Query (in Excel, you would click on the table and then Data > From Table/Range > Select My table has headers and click OK).
In Power Query:
You'll probably have to change the TimeID type to date if you want to use the dates for anything, because it will probably come in as date-time type--I won't use the dates here though, so you could skip changing the type (otherwise, right-click the TimeID column > Change Type > Date)
Then use Group By to aggregate values and set the stage for the calculation you want (select the StateID > Group By > and setup the groupings like below and click OK)
You should see something like this:
Then add a new column with your calculation (Add Column > Custom Column > Set it up like below and click OK)
You should see something like this:

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