CFCHART Title dynamically populated - coldfusion

I'm using CFCHART to generate awesome charts on the fly.
It would be nice to dynamically change the title of the chart based on selection criteria.... and I've been attempting to do that by setting a string, graphTitle, that conditionally populates based on selections. All I want to do is simply start a new line for each criterion.
For instance: Suppose I have a chart that has a large number of selection criteria in it. I would want the chart title to look like this: (Break, of course, indicates the end of a line)
Fiscal Year 2006 to projected 2013 (Break)
Hires of African American Heritage candidates (Break)
Whom are Female
From New Mexico, California, Texas and Colorado (Break)
With an Age of 29+ (Break)
With a breakdown of Degree Achievement:
I tried using the <SPAN> and <BR /> tags in the title. With no luck.
Any other ideas?

If you mean you want to add line breaks into the chart title so it "wraps" you might try adding ascii coded line breaks like so...
<Csfet linefeed = chr(10) & chr(13)/>
Then your variable would be
<cfset mytitle = "fiscal year 2006 to projected 2012 #linefeed# Hires of..."/>
And so on - you get the idea. Note: you might need "just" chr(10) or you might need both. you'll need to experiment. I don't "know" that this will work. If it were me and I wanted something that complex to decorate the chart I think I would draw a plain "undecorated" chart with only x and y axis labels present and then set up my title outside the chart using HTML. I would have better control that way.
Anyway if that doesn't work try fiddling with the "style" attribute. You can provide an XML () var with all sorts of options - but it is not well documented I'm afraid. Ray has some stuff on his blog regarding this.

Related

How to replace a column value using PowerQuery editor

I'm relatively new to Power Query. I'm looking for the best way to replace a column's value as below.
The column has date values in a mixed format such as below.
09/16/2022
09/20/2022
09/26/2022
09/30/2022
10-01-2022
10-03-2022
10-05-2022
I'm looking to standardize and make the format generic as below.
09-16-2022
09-20-2022
09-26-2022
09-30-2022
10-01-2022
10-03-2022
10-05-2022
It seems one of the ways to implement this is to use Advanced Editor and build M queries to implement the replacement, functions like Table.TransformColumns and Text.Replace.
'can't figure out the exact code to be used with this or if there is a better way.
Looking for suggestions. Thanks.
If you're a beginner, let the UI write this code for you. Highlight the column by clicking the column header, go to Transform on the ribbon and click Replace Values. Replace "-" with "/" and click OK.
Finally right click the column header again, click Change Type and then select Date.
In M code you could use:
Table.TransformColumns(#"Previous Step",{{"Column Name", each Text.Replace(_,"/","-")}})
As an example:
let
//create sample table
Source = Table.FromColumns(
{{"09/16/2022",
"09/20/2022",
"09/26/2022",
"09/30/2022",
"10-01-2022",
"10-03-2022",
"10-05-2022"}},
type table[dates=text]),
//replace "/" with "-"
Normalize = Table.TransformColumns(Source,{{"dates", each Text.Replace(_,"/","-"), type text}})
in
Normalize
Source
Results
Notes:
Original data is dates as text strings
Final data is also dates as text strings
To convert the strings to dates, you could use, instead, something like: Table.TransformColumns(Source,{{"dates", each Date.From(_, "en-US"), type date}}) but the separator would be in accord with your Windows Regional date settings.

powerBI map doesnt show cities

Im trying to show provinces and then drill down to show cities in powerbi map (Aug, 2018 version).
My problem is it does show provinces but when I drill down to get a look at cities, it doesnt show anything.
I also changed column "city" to "place", but nothing happened.
(Note: they are Iran's province/cities, maybe this problem is related to that. because when I change for example my city "Kāshān" from province of "Isfahan" to "Redcar" or "London" it loads nicely on these two cities)
So, what is the solution?
Thanks a lot in advance.
Create a new column called "Location" or "Place" by merging the City and Province columns. You can use a comma (,) as a separator. For example - "Alabama, USA".
Then change the category of the new column to Place. This will solve your issue. The map will be plotted correctly.

Selectively displaying data into the Long Text Viewer

I have four levels of report filters: Month, Year, Region and Country, all of which were set as Page Level and Report Level filters.
The data is structured like so:
And basically, this is how it looks like if all slicers are set to All:
This is obviously not helpful and doesn't really give proper context to the data if viewed by anyone since it just listed down everything in the Comment column.
So is it possible to selectively display data from the Comment field into the Long Text Viewer (ie: display nothing if all Slicers were set to All, only display comments for the particular country/month, etc.)?
Depending on how you want the exact display logic to be, you may find the HASONEFILTER() and HASONEVALUE() function useful in this case.
The following is an example where a new measure is created, and it'll display the comment (concatenated by newline which will be handled later) when there are any filters applied to the column Month, Year or Country; or it'll return an empty string.
Useful comment =
IF(
HASONEFILTER(Data[Month]) || HASONEFILTER(Data[Year]) || HASONEFILTER(Data[Country]),
CONCATENATEX(Data, Data[Comment], "\n"),
""
)
The Long Text Viewer provides a format option called Newline starts with, which allows us to split the measure we created (which is a long concatenated string containing all filtered comments) back to separate lines for display purpose.
The following shows the result when no filter is applied:
The following shows the result when filter is applied:
EDIT:
Same result when slicer is a dropdown:
Another example, display nothing when year is 2016:
Useful comment 2 =
IF(
CONTAINS(DATA, DATA[Year], "2016"),
"",
CONCATENATEX(DATA, DATA[Comment], "\n")
)
When Year = 2016:
When Year = 2017:

When using a date column, first and last bars are cut in half

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.

How to extract rows in Excel with a given name by function 'xlsread' in Matlab?

I have 100 Excel sheets of financial statement to extract selected data. For instance, the first sheet is from company A, its 'Total assets' item is in A10, but in the second sheet the 'Total assets' is in A17, the third in A12....
So every financial statement's items have different positions in their Excel sheet. Is there any way I can extract them by specify their name, such as 'Total assets', 'Other earning assets' etc, then I don't need to read their location one by one.
Basically, you're going to need to read the sheet in, search for the term, then use that location as an anchor. If, once you find the term, the format is relatively consistent from there, you should be ok. You might search File Exchange, but I didn't find anything.
Well - to make it that you personally don't have to read is simple. But your program will have to - as excel doesn't feature any shortcuts in this way.
I typically use structures like this:
[~,~,table] = xlsread('myfile.xls');
labels = table(:,1);
labels(~cellfun(#ischar,labels))={''}; % just sanitizing
index = ismember(labels,'Total assets');
table_line = table(index,:)