So I have a table that shows the index number of the rows. I've maximized the width of the table to be the exact same as the page. Unfortunately the column with the index numbers are now annoying wide so I'm wondering if there's a way I can either set a cap how wide the first column is or make all the columns in the table adjustable? Thanks!
Setting column widths in the Google Visualization API Tables is really annoying. HTML tables set the column widths based on the first row of data in the table, which for the Google Visualization API is the header row (normal table construction would put the header row in <thead> with <th> tags, but Google puts it in <tbody> with <td> tags, which is why it defines the column widths). The API does not provide any method to assign css or classes to the individual cells in the header row, so you have to write javascript to parse your table and set appropriate classes/CSS to handle your column widths. Furthermore, since the table gets deleted from the HTML and redrawn whenever the user clicks column headers to sort the table or clicks the page buttons (if paging is enabled), you have to re-assign classes/CSS to the cells whenever the table is redrawn. To complicate things even more, if you have a height assigned to the table so that the table will scroll when it gets too big, the API actually draws two tables in order to create the fixed header effect.
Normally I'm an advocate of using the Google Visualization API, but in the case of the Table visualization, it is sometimes more trouble than it is worth. You might have an easier time working with another library, or creating your own custom table visualization.
If you want to continue using the Table visualization, here's some code to get you started:
google.visualization.events.addListener(table, 'ready', function () {
var headerCells = document.querySelectorAll('#myTableDiv table tr:first-child td');
for (var i = 0; i < headerCells.length; i++) {
// access the header cell element with headerCells.item(i)
}
});
Related
I have data like this:
It comes from REDCap, and as you may be able to tell, the data in the far right columns are repeated variables about each "protocol_title" (the far left column). I.e. "Love it" and "I want a disc instead" are both about "study 2"
I've imported the data into Power Bi and currently I have this:
What I'd like is for the top left visual to only have one row per study (with columns such as principal investigator and method of image transfer, i.e. columns that had data in the first row) and a visual on the lower left with all the right-most columns.
By switching the top visual from a table to a matrix I can kinda accomplish this:
But it adds a bunch of unnecessary columns. As an alternative I thought I could add a filter to the top visual that would filter to "redcap_event_name"=="protocol_information" which would only be those top rows.... but given the visuals are linked, if I do that it removes everything from the bottom visual. I'd like to keep the link between the visuals so that if I select "study2" in the top visual, it'll highlight relevant study 2 information in the bottom one.
So my question is: what's the best approach for making the visuals I want? Are there special settings for visuals? Do I need to do something to the data first in the query? How should I go about this?
You might want to rework you data structure. At first glance, your flat source table could be parsed into two tables :
Protocol
Survey
This can be done in PowerQuery.
For Protocol :
Select columns A to R.
Filter on redcap_event (?) starts by "protocol_info"
Delete empty rows
For Survey
Select columns A (to keep the protocol ID and be able to link both tables), T and U.
Filter on redcap_event (?) starts by "survey"
Delete empty rows.
You should end up with the two table with a one-to-many relationship between Protocol[Protocol_ID] (column A) and Survey[Protocol_ID] (same)
And it should make everything much easier: visuals, calculations...
so, I got 3 xlsx full of data already treated, so I pretty much just got to display the data using the graphs. The problem seems to be, that Powerbi aggregates all numeric data (using: count, sum, etc.) In their community they suggest to create new measures, the thing is, in that case I HAVE TO CREATE A LOT OF MEASURES...Also, I tried to convert the data to text and even so, Powerbi counts it!!!
any help, pls?
There are several ways to tackle this:
When you pull a field into the field well for a visualisation, you can click the drop down in the field well and select "Don't summarize"
in the data model, select the column and on the ribbon select "don't summarize" as the summarization option in the Properties group.
The screenshot shows the field well option on the left and the data model options on the right, one for a numeric and one for a text field.
And, yes, you never want to use the implicit measures, i.e. the automatic calculations that Power BI creates. If you want to keep on top of what is being calculated, create your own measures, and yes, there will be many.
Edit: If by "aggregating" you are referring to the fact that text values will be grouped in a table (you don't see any duplicates), then you need to add a column with unique values to the table so all the duplicates of the text values show up. This can be done in the data source by adding an Index column, then using that Index column in the table and setting it to a very narrow with to make it invisible.
I can see that some tables have different icons, and I would like to be able to decide which icons is associated to a table.
I have tried creating an empty table with just measures in it, but the icon stays the same as for regular tables. I cannot figure out why the first table called "Totals" in my example of tabular model gets a different icon in Power BI Desktop field list.
I would like to find out how Power BI Desktop decides to assign which icon to a table.
See screenshot, the green arrow is pointing to an icon that is different from all the other tables in the model.
You can make any table look like the one you have on the top:
Hide all columns in a table (right-click a field, select "Hide");
Once all columns are hidden, save pbix file, close, re-open.
Essentially, the icon changes when a table contains no visible data fields, but has DAX measures. Designers often use this trick to organize their measures in one place, instead of assigning them to many different tables.
I've noticed that If you have a table in the Data Viewer in Power BI desktop such as this:
Then, if you insert the same table in a Table Visualization, the table will only display distinct values of the categories:
How can you set up a Table Visualization so that the data is displayed as it is in the Data Viewer where all observations are displayed?
Unfortunately, Power Bi Desktop currently does not have an option to display all observations in the Table Visualization(Oct 2018). I am optimistic the Power Bi team will correct this problem in a future release. If you feel strongly about this feature, please go to the Power Bi improvement Idea post and add your vote.
I'm answering this question to perhaps help others who come here looking for a work around until it gets implemented.
There is currently one work around that I know of: Add an index column to the data table, add this column to your table visualization, then shrink the column width of the index to hide the data. This is not a desirable work around, but might get you a solution in a pinch until the feature is implemented.
So for your example, to add an index column to your table, go to Edit Queries -> Add Column -> Index Column -> From 1
Then - back to your report, add the Index column to the Table Visualization and make sure you select Don't Summarize for the Index Column values tab pull down.
Once the index column is added to your table, and you sort by the index your table visualization should look like the following:
The last step is to hide the index column by shrinking the column width of the index column. Before you do this, you need to turn off word wrap for the columns and the values. Go to the paint roller and in Column Header and Values make sure you turn word wrap off:
then your final table will look like the following with all of the values required. The grey box is my mouse over the shrunk index column and wont show up for you unless you mouse over that area:
I have multiple tables in my app. In the app I cannot control the numbers of columns of the strings lengths in the column. Also I cannot control the numbers of columns of the orders of the columns.
Right now i have 4 tables in a set and one table in another set. I will put only the headers as the other data is confidential in this image.
The problem I encounter is: since the string length in a column in the table is not the same as the same column in other table. The width of the columns are not the same within a table set. I have tried to check on page load the length of the columns but the tables is not drawn on page load. When i say a table set i refer a list of tables with same properties, same columns number and name.
I cannot set fixed size on a certain column because I am not able to know if for next table set how the columns distribution is.
How can I make all the columns to look alike? How can I catch event when the table is fully drawn?