Lock scale on multiple axis ssrs - sql-server

I have a chart in SSRS (reporting services) that is using both the primary and secondary y axis to plot 4 different years of data. I am also using a series group for multiple values stacked. The problem that I am having is that the 2 axis's are not using the same scale so the numbers look like they don't match the table that is also on this report. How can I lock the 2 axis's so they use the same scale. I would like to still use auto axis if possible so I don't have to calculate the max and min myself.

Right click an axis and select "Axis Properties". In the Axis Options tab you can set the minimum and maximum values of the axis, you want these values to be set to a value (Not Auto) and for both graphs to hold the same values. This is to say for example that a minimum = 0 and maximum = 10 that the graph will start at 0 and end at 10 , if you have a value of 11 it will just hit the top of the graph. You will also want to set the interval. An interval of 1 would make the axis read 0,1,2,3 etc, an interval of 2 would make it go 0,2,4,6 etc and again you want the same value set on both graphs.

Related

How to efficiently access Microsoft.Maui.Devices.Sensor.Locations in SQL Server

This is more a design question so please bear with me.
I have a system that stores locations consisting of the ID, Longitude and Latitude.
I need to compare the distance between my current location and the locations in the database a only choose ones that are within a certain distance.
I have the formula that calculates the distance between 2 locations based on the long/lat and that works great.
My issue is I may have 10 of thousands of locations in the database and don't want to loop through them all every time I need a list of locations close by.
Not sure what other datapoint I can store with the location to make it so I only have to compare a smaller subset.
Thanks.
As was mentioned in the comments, SQL Server has had support for geospatial since (iirc) SQL 2008. And I know that there is support within .NET for that as well so you should be able to define the data and query it from within your application.
Since the datatype is index-able, k nearest neighbor queries are pretty efficient. There's even a topic in the documentation for that use case. Doing a lift and shift from that page:
DECLARE #g geography = 'POINT(-121.626 47.8315)';
SELECT TOP(7) SpatialLocation.ToString(), City
FROM Person.Address
WHERE SpatialLocation.STDistance(#g) IS NOT NULL
ORDER BY SpatialLocation.STDistance(#g);
If you need all the points within that radius, omit the top clause and change the predicate on STDistance() to something like SpatialLocation.STDistance(#g) < 1000 (the SRID I typically use has meters as the unit of measure, so this would say 'within 1 km').
https://gis.stackexchange.com/ is a good place for in-depth advice on this topic.
A classic approach to quickly locating "nearby" values, is to "grid" the area of interest:
Associate each location with a "grid cell", where each cell is a convenient size. Pick a cell-edge-length such that most cells will hold a small number of values and/or that is similar to the distance range you typically query.
If cell edge is 1 km, and you need locations within 2 km, then get data from 5x5 cells centered at the "target" location.
This is guaranteed to include all data +- 2 km from any location within the central cell.
Apply distance formula to each returned location; some will be beyond 2 km.
I've only done this in memory, not from a DB. I think you add two columns, one for X cell number, other for Y cell number.
With indexes on both of those. So can efficiently get a range of Xs by a range of Ys.
Not sure if a combined "X,Y" index helps or not.

How to plot Total Return?

I'm looking at various libraries to see how I can plot the total return of a stock within the time period specified. The algorithm is simply (data - dataMin / dataMax ) * 100 for the % return across the time period. I'm currently using recharts but it seems like there's a limitation in their library as I cannot alter the Y Axis to plot that number AND the price at the time the mouse is hovering over.
Thanks!
Edit:
I have something like this at the moment but as you can see, the Y Axis scaling is capped at ~1000% whereas the max should be ~2800%. https://codesandbox.io/s/recharts-issue-template-czf5t

SSRS - Display only Top N Category Groups excluding duplicate groups at the end in Bar Chart

Consider the following table
I need to generate a bar chart with the Category Group = "Country". The chart should only display the top 3 Groups based on the count of records for a country. I have already applied a filter for the Category Group specifying the Top N Condition as 3 for Count(Country). The chart generated, applies the filter as expected based on count, but i need only 3 bars to be shown even if there are bars with duplicate values.
Below is the chart that I get.
Expected Result
Now I know that, i can create an additional column in my dataset with ranking values and then apply a filter on this column to get the expected result (i have tried this, and it works)
Is there a way to achieve the expected result without changing the underlying Dataset?
Note: The dataset shown above is a highly simplified version of my dataset. In reality i have a huge dataset with a lot of columns. The same dataset has been used for various charts (with groupings on different columns).
This was an interesting question as I've always just "solved" the tiebreaker in the dataset without much thought. However, I do see a fairly easy way to use the rnd() function to dissolve the ties as long as you don't care which of the tied countries is shown:
=(Count(Fields!Country.Value) * 1000) + (Rnd() * 100)
Which essentially just weights the count per country into the thousands and then tiebreaks with a random small value:
New York: 30XX
France: 20XX
China: 10XX
Italy: 10XX
Singapore: 10XX
If you wanted to actually solve the tiebreaker with an alphabetical preference, you could do something similar but incorporate the numeric value for the first letter of the country etc...
I just found out, I could use an x-axis minimum of 0 and an maximum of 10.5 together with an interval setting of 1.
So, I was able to achieve a top 10 limitation and the axis labels show the names - (it may be a side effect but when I changed the axis maximum to a whole number, the axis no longer shows the names but numbers).
I was not really happy with the other approaches. They seems much of an overkill to me for such a simple requirement like limiting the number of bars shown in a chart.

how to determine if 2 line graphs with different values are same

I'm trying to compare line graphs with completely different values and scale.
On X-axis i have values from 0-30 (Days) and on Y-axis i have stock values.
My task is to compare the data of last 30 days with a huge database which already contains different stock values.
is there any way to compare the shape to 2 graphs irrespective of what values were used in y-axis?
Thanks in advance
First Graph
Second Garph

Google Earth Engine: How can I perform the comparison of two maps (different resolutions)?

I have two maps- Hansen 30m forest cover and another product of 500 m resolution. I want to look on correlation between these two maps at 500 m resolution.
Does anyone know, how to aggregate one map (30 m) to the resolution of another (500 m) in Google Earth Engine, so they will perfectly overlay?
Thanks in advance!
In Google Earth Engine you don't have to worry about it: the scaling happens automagically and they will overlay perfectly. Of course lack of control can be an issue for certain applications, but to my knowledge there is not much you can do about it.
Now, to the point: scaling Hansen's map (Global Forest Change - GFC) to lower resolution map:
The GEE loads the data internally at native resolution and then generates down-sampled versions at multiples of two, until the entire image fits in a single tile. Then, GEE fetches the down-sampled pixels from the nearest higher level of the pyramid, and re-samples those to the requested scale. For bands that cannot be interpolated, like GFC's "lossyear" (pixel value indicating the year loss occurred), the GEE selects the first value (of the four "child" values) at each pyramid level.
In other words, if we consider example of a treecover2000 band with the following pixel values
10 20
30 40
the down-sampling will result in value '25'. The categorical values like 'lossyear' will scale differently:
1 2
3 4
Here the result will be simply "1"

Resources