Using VBA to scale excel graph X-axis? - vba

I'm using a macro to generate graphs from a table such that the x-axis is a time stamp(date, time) and the y-axis is for the data at that time. So far, there is no problem getting this to work but the result is a graph that has "blank space" before and after the data(roughly 5-10 minutes before and after on a 1-hour time-frame). I have space constraints and this cuts into them so I'd like to utilize the entire plot area. Can I eliminate the blank space by extending the data to end of the plot area somehow? Any help is appreciated.
Additionally the files I need to use are for different time frames and lengths of time(ie, different length of excel rows). Is there a way to only graph the rows with content instead of a "worst-case scenario" like using A2:A100000 because I know it will never be greater than 100,000 rows?

Related

power bi: dynamic y-scale values based on data

I'm building a dashboard in power bi and I have a dataset with a few percentages. There are several categories of data, but only one category is shown at a time. What I want to do is to dynamically change the y-axis values to reflect the data. At the moment, it's done automatically, but it makes the data look "worse" than it is, so I want to take the min and the max for that one category and add let's say another 10-20% to it, and use those values as the new scale. For example, if my data starts at 41% and ends at 63%, power bi automatically scales the chart between around 40% and 65%. I want to take these values, add 10% on each side and have the chart start at 30% up to 75% (roughly).
Is there a way to do this?
Thanks
If your visual is a line diagram then you can solve it by adding two additional measures to the plot:
y_top = MAX([pct_measure])+0,1
y_bottom = MIN([pct_measure])-0,1
Add both to the line diagram and then set their line widths to 0.
It's a variation of this:
Power Bi Tips - Center X-axis on a line chart

How to zoom chart specific area in Excel Using Macro

Hy Everyone,
I have a sheet with chart that has many values with X-Axis. These values are many in numbers some time I feel difficult to view them, So I want to zoom the any area of the chart by selecting any where in the chart. I used recorded macro that only zoom sheet not Chart / Graph. But I want a macro that can zoom any specific area of the chart or graph any where I click or select..
Here is pictures of the sheets...
My suggestion is to limit the x-axis (minimum and maximum) and probably limit the max value of the y-axis. This way it will only show a part of the data within the chart which might result in a better resolution to view then. But there is no built-in zoom like you described. Therefore you will need to code that on your own.
(Sorry for the german screenshot …)
As you see in the example above. I have total data in x-axis from 0 to 450 and in the second chart I limited the x-axis from 100 to 200. Both charts have the same source data, but the second only shows a part of the first.

PowerBI Dynamic Time Series BarChart

Adding on my previous question here: TimeSeries question
I would like to plot a unit capacity chart over a Time series (which contains a range of dates set by the user).
The chart I am trying to plot is as follows:
For each Unit Name, I have start and end date for the unit capacities, as shown in the PowerBI table as below:
4 sub questions:
How to plot these capacities over time? Maybe using some DAX functions?
Do i need the SSAS cube to solve this problem or can I do all the work inside PowerBI desktop? If not, is there a better way for example in SSRS?
Is there a way to make the x-axis time series dynamic as specified by the user?
Adding to this, after Leonard's response. After converting the OutageStartDateOrig, and OutageEndDateOrig values I tried to create the calculated column as suggested in the youtube link {enter link description here}. However, the DAX formula as shown in the video gives out a syntax error for me stating that the '.' is incorrect when specifying the range of dates. Any ideas for this? [Screenshot below]:
To create such a visual, I'd recommend an area chart (or stacked area chart) with the date on the axis, the unit name on the legend, and the capacity on the values. You could also do it as a stacked column chart too. However, then each date will be broken into discrete columns. See below image.
In terms of data manipulation, you'll need to convert the data with the date ranges you have above into a row for each individual date & unit. E.g. the first row, instead of being 11/2 to 13/2, would be expanded into 3 rows, one for each date.
You can do this in Power Query as you bring the data into Power BI Desktop, or in DAX after bringing it in. There are several solutions to this outlined in this thread (https://community.powerbi.com/t5/Desktop/Convert-date-ranges-into-list-of-dates/td-p/129418), but personally, I recommend the technique (and video) posted by MarcelBeug (https://youtu.be/QSXzhb-EwHM).
You'll also want an independent list of dates (with no gaps) to join the final date column to - otherwise your visual will skip dates when no units had capacity. By default, the chart will begin on the first date with data and end on the last date with data, so in that sense it is dynamic, but you can add a date slicer to give the end-user more control.
Area chart on top, column chart on bottom, date slicer on right filtering Jan-Mar.

QlikView: Displaying Millions Label Instead of Thousands

I am using QlikView. In the program I made a bar chart. For my expression I defined thousands, millions and billions labels. The chart is showing thousands label and corresponding numbers (which are larger), but I want it to show Millions label (smaller numbers). How can i do that?
If you set the Static Step size on the Axes tab you can force QlikView to use the abbreviation you want otherwise it will use its best fit algorithm.
So this:
Becomes this:
By doing this:

Excel 2007 - External Datasources (Tables) Changing Absolute Ranges

Excel 2007 is driving me nuts. I have several charts set up that I refresh periodically against some data in a SQL database. However, every time I refresh them, Excel bumps any absolute ranges I have for the charts to view this data by the amount of new records returned from the query.
The data is time related (I have a record for each minute of the day), and I want the chart (line chart) to be fixed in size... instead, Excel wants it to dynamically change, and thus it adds the extra rows to my named ranges.
Is there a way to prevent Excel from updating absolute named ranges when new data from a data source is returned? I hope this makes sense.
How are you defining your named ranges? I'm assuming your are just using cell references, if so it may be worth looking at the offset function, particularly if you are dealing with fixed size ranges (e.g. minutes in a day).
For example, if you had column headers in the first row, your minutes were in column A and you had exactly 1 row for each minute your offset formula would look like:
OFFSET(A2,0,0,1,1440)
and is defined as
OFFSET(StartCell, OffsetRows, OffsetCols, Width, Height)
Because any of the values within the arguments can also be formulas, OFFSET is a very useful function in defining ranges.