I have data about earnings occurred on some dates:
['2013-02-13',100],['2013-03-20',200],['2013-04-11',160]
and data about costs occurred on some other dates:
['2013-02-22',60],['2013-03-04',90],['2013-03-25',110]
So X-axis is continuous one (date), and Y-axis represents earning/cost values (number). I'd like to represent these two date-value series on the same chart. They share the same timeline but events occurred on different dates?
Is this possible?
Yes, you just need to join the two data sets, using the google.visualization.data.join method:
var joinedData = google.visualization.data.join(data1, data2, 'full', [[0, 0]], [1], [1]);
If you draw a chart using this method, you will have two series of data that can be charted together. See this example: http://jsfiddle.net/asgallant/XF7JE/
Incidentally, with your dates input like that, you will get a discrete axis, not a continuous axis. You need to input the dates as javascript Date objects to get a continuous axis.
Related
I want to split graph in two halves of 15 day each using dates
i have tried using Top N filters Top and Bottom but when date range is changed i have duplicated graphs.
Split is happening using above filter but when i reduce date filter range duplicate data is shown in two graphs
i tried Flag = IF(DAY(MAX('Table'[Date]))<=15,1,2) as well but was getting data not in sequential order
I'm new to this any help will be thankful.
I just split it in half, rather than by 15 days. But you could change the math to use 15 days instead, if that's what you still want. Regardless, seeing this might help.
I started with a table like this, called Sheet1:
Then I created a chart like your original:
Then I created this DAX measure:
Chart Selector =
var minDate = CALCULATE(FIRSTDATE(Sheet1[Date]), ALL(Sheet1[Date]))
var maxDate = CALCULATE(LASTDATE(Sheet1[Date]), ALL(Sheet1[Date]))
var midDate = minDate + (DATEDIFF(minDate, maxDate, DAY)/2)
return
IF(CALCULATE(SUM(Sheet1[Date]),FILTER(Sheet1,Sheet1[Date]<=midDate)),"First","Second")
(You could change the midDate variable's calculation, above, to one that does 15 days instead.)
Then I made two copies of the chart and, in each copy, I added the new measure to the chart's filters. In the first chart's filter, I filtered for if it contains "First." For the second chart's filter, I filtered for if it contains "Second."
My end result looks like this:
I have a query in Power BI that takes two parameter: Start Date and End Date.
Whenever I pass these Dates it return a table of Date that contain few columns created according to this range of date such as Date, QuarterofYear, Year, MonthName......etc.
Can we create a mapping data flow in ADF that takes two parameter as input and return a calculated table according to provided dates?
Is there any function that return the range of dates?
For your request: "I want that I pass two date Start Date and End Date in ADF Mapping Data Flow , and Data flow will Create a column such as "Date" that contain that number of Date rows. Is there any function for this? Exam. Start Date=20-01-2019, End Date=20-01-2020 Then Date Column Values should be: 20-01-2019 21-01-2019 ......... ......... 20-02-2020", according the Data Factory documents and my experience, the answer is no, we can't achieve it in Data Flow.
There is a solution to this, but it is a bit tricky.
TL;DR
The general data flow looks like this:
We need a dummy source with exactly one row which contains whatever.
Then we derive a column where we use the mapLoop() expression to create an array of all the dates we want to get rows for.
Finally, we need to flatten the array column which will result in one row per array entry and thus one row per date.
Walkthrough
Source dummy
Each dataflow needs a source and we need exactly one row to make our dataflow work. To achieve this I've created a dataset called empty of type CSV in my data lake which has this content:
empty
""
This is our source definition:
And its result looks like this:
Derived column days
This is where the magic happens!
We create a new column dates which is an array of all the dates we want to have in our date table:
In this scenario we want a date table starting on 2019-01-01 and reaching one year into the future. The full expression looks like this:
mapLoop(
addDays(currentDate(), 365) - toDate(2019-01-01),
addDays(toDate(2019-01-01), #index)
)
This is what happens here:
the mapLoop() function builds an array of elements. You specify the number of elements you want to have and the lambda expression to calculate each of the elements. For example, mapIndex([1, 2, 3, 4], #item + 2 + #index) results in [4, 6, 8, 10]
addDays(currentDate(), 365) - toDate('2019-01-01') is the number of days between our start (2019-01-01) and end date (1 year in the future from now) and thus the number of dates we want to have in our resulting array.
addDays(toDate(2019-01-01), #index) calculates each array item by adding #index days to our start date. This is executed for the number of days we've calculated before and #index is the array position. Thus, the first element of the array will be 2019-01-01 + 1, the second 2019-01-01 + 2 and so on.
Our stream now has these columns:
Flatten
Finally, you need a flatten transformation which will expand each item in your array to its dedicated row. We can also dismiss the useless empty column in this step:
And this finally results in what we wanted to achieve:
References
Data transformation expressions in mapping data flow
I am trying to make a chart with indicators that are alsoe headers of a matrix. My dataset has 4 variables (Date, Indicators (A,B,C,D), Currency and Value). I have a matrix where the rows are the "Currency", the columns are the Indicators A and B and the values are "Value". In my chart, the x axis is Indicators (C and D), the legend is the "Currency" and the values is "Values". I want to make this chart ignore what is selected in the matrix columns but I need it to be responsive to the matrix rows (currency). I tried some filters but it didn work.
In the Fig 1 (link below) we can see the screen if no filter is selected. And I want to select a currency (row) or a value in the matrix. But if I do it, my chat turns blank (Fig 2) where I want to see the values of C and D for the selected currency.
How can I do it?
All data and pibx are here!
Tks
Look at using the All() function, this restricts filters from affecting your measures
The data frames are not similar in any way. They do not have the same values. I want to be able to compare one column from one df with another column from the other and graph them. For example, one df has a column named "Offical poverty total" and another df has a column named "violent crime rate". I want to be able to compare these two.
I tried df['Offical Poverty_Total'].append(crime['Violent crime'])
but this isn't what I was looking for. To make it simple, I want to have a new table with the two columns and be able to analyze the new table.
You're looking for
pd.concat((df['Offical Poverty_Total'], crime['Violent crime']), axis = 1)
This will align their indexes, so if you've changed the row ordering of the dataframes and want to just glue them together in the order you see them in, do
pd.concat((df['Offical Poverty_Total'], crime['Violent crime']), axis = 1, ignore_index = True)
When I use a column type of date, the first and last bars in the ColumnChart are cut in half. It seems to be rendering from mid-bar. It doesn't do this with non-date sets of data.
Is there any way to fix this so that the complete bars are rendered, with some extra padding?
http://jsfiddle.net/7tHVN/
Setting the viewWindowMode does work for dates, apparently. Adding the following to my chart options, where the min and max are dates prior to and beyond the 1st and last date values, worked for me, at least.
'hAxis': {'viewWindowMode': 'explicit', 'viewWindow': {'max':new Date('2012-10-02'), 'min':new Date('2007-07-02')}}
See also: Column Chart crops the end bars in the Google forums.
I had this exact problem (my labels were also weirdly misaligned) and it drove me crazy trying to figure it out. hAxis.viewWindowMode usually fixes issues like this, but it's not possible to use this with date values.
What I ended up doing was just scrapping the date type entirely, specifying the string type for that column instead, and converting each JS date object to a string representation before adding it to the DataTable, thusly:
data.addColumn('string', 'Date');
data.addColumn('number', 'Performance');
var dates = [new Date('2012-4-12'),
new Date('2012-4-13'),
new Date('2012-4-14')];
var performance = [59, 35, 86];
var dateString;
for (var i=0; i<dataForChart.length; i++) {
dateString = (dates[i].getMonth()+1)+'/'+ // JS months are 0-indexed
dates[i].getDate()+'/'+
dates[i].getYear();
data.addRow([dateString,
performance[i]]);
}
This forces the chart to render with a discrete rather than continuous axis, which fixes the cut-off bars problem. As long as your data and dates are spaced along even intervals (once a day, once a week, etc.) and you pass them in in the proper order, this approach should work.
There's more info on discrete vs. continuous axes in the Google Viz docs: https://google-developers.appspot.com/chart/interactive/docs/customizing_axes
Easy Fix here 😎
If you double click on the first column to access the Format Data Point you can widen the individual column width to match the same visibility as the other columns. Same applies to the last column when 'cut off' due to date and axis
This looks like a bug on Excel, easy fix, change the graph type to stacked bar, then switch back to stacked column, and your graph will be fixed.