We have problem with table component in our dashboard. To make lazy loading we are using the same table component, and fill it with data from our mdx queries. The problem is, that each query can return different number of columns and table fixes on one size at the moment of first loading of data. I can reload data, but only if the columns count is identical.
To put it simple, how can I change number of columns in already initialized table?
put this function in to Pre Execute
function f() {
this.chartDefinition.colHeaders = [];
this.chartDefinition.colTypes = [];
this.chartDefinition.colFormats = [];
}
hope this help
Related
I am new to PowerBI and I am facing a challenge with creating a calculated column that will get updated automatically as the dataset keeps getting filtered. My dataset looks like this -
I have created the Deliverable_Milestone_Match column using the formula -
Deliverable_Milestone_Match =
IF(
Sheet1[Issue_Type] = "CO Deliverable",
VAR _sel = SELECTCOLUMNS(
Sheet1,
"MilestoneIssueKey",
[Issue_Key]
)
RETURN
IF(
Sheet1[MilestoneIssueKey] IN _sel,
"MAPPED",
"UNMAPPED"
),
"MILESTONE"
)
Now, the challenge is, that I will need to apply some filters to this dataset, and since my calculated column references other columns in the data, it also needs to change accordingly. For example The formula is looking up the presence of MilestoneIssueKey in Issue_Key, and it is populating MAPPED if it gets a match, and UNMAPPED otherwise. Now, if I apply a filter that removes a specific unique Issue_Key, then the corresponding MilestoneIssueKey won't have a match anymore, and the Deliverable_Milestone_Match value should change to UNMAPPED now.
I would appreciate it if anyone can help me with this. I am not even sure if this can be achieved via DAX or whether I will need to use Power Query for this.
Thanks in advance!
You first issue is the following:
[...] calculated column that will get updated automatically as the dataset keeps getting filtered
Calculated columns aren't refreshed dynamicaly as filter context evolves. As explained here :
Since calculated columns live at the same level as your tables, they are only calculated when you first define them and during a dataset refresh.
So, in that regard you should try to solve your problem using Measures.
I have a very large Tableau workbook, which takes a very long time to load. I have determined that this is due to some very large calculated fields which I want to replace to improve the load time.
My plan is to have this calculated field replicated on the database level however, I am unsure what the best approach is and was hoping someone can help me.
The calculated field is essentially a large mapping table, which roles up an area (say area 2) to a higher level named area 1. This is several lines of code and unfortunately I am not able share this due to work.
e.g.
IF [area_2] = "abc" THEN [area_2]
ELIF [area_2"] = "def" THEN "xyz"
ELIF [area_2"] = "ghi" THEN "mno"
....
....
END
My initial idea was to create a view on top of the database table these attributes come from with a IF Statement. However I have come to understand the views cannot be created with PL/SQL If statements.
I have tried to begin learning PL/SQL elements (i.e. Procedures, Packages, Functions), but finding it hard to determine what is the correct option I should go for.
Any guidance will be greatly appreciated.
Thanks
I think you have three ways to solve your problem
If a record always have the same value after the calculation
You can store the calculation value: add to your table columns to store the results of the calculation and create a TRIGGER in your table that calculate the values after every insert.
Create an Materialized View: If your table don't have a high frequency of inserts, you can create a MATERIALIZED VIEW, that store the view result after every insert.
Materialized View Docs: https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_6002.htm
If a record can change the value after the calculation
Create a view using CASE WHEN or DECODE if the calculations are simple as your example, if they're not, use a FUNCTION that return the value passing your value and params to calculate the value.
Using datatables in server-side mode, with YADCL for filtering, is there any way that I can programatically extract the record IDs (e.g.
column 0 contains those IDs) for the entire filtered recordset (not just the paginated results shown) such that I can then carry out an action on that recordset.
Example: a 'customers' database table contains 80k records and I use YADCF filtering to narrow that down to a recordset of 1k customers, 20 of which are displayed on the web-page. I would like to have a button on the page, labeled 'Mark all filtered records', that when clicked, fires off an ajax script that changes the 'mark' field on the filtered 1,000 records from 0 to 1.
I can handle the marking of the records independently of datatables, but I don't know how to programatically work out which records need marking i.e. I need to extract some form of recordset identification that I can then use to target with my SQL UPDATE action. Any ideas anyone?
I had a similiar problem, here's what I did:
added a hidden input-field
used the drawCallback-option of Datatables to trigger a function that wrote the ids of all active (filtered) records to that input-field
on callbacks to the server, included the content of that input-field
The tricky detail was the drawCallback-function:
function (settings) {
dtObj = this.api();
var dtData = dtObj.column(0,{ search: 'applied', selected: true }).data().toArray();
$("#dtdata").val(JSON.stringify(dtData));
}
the first argument of that column-call is the index of the column you're interested in (0 has my index)
that 2nd argument selects all rows that matched search/filter-criteria. They also work with yadcf-filtering!
I have a normal html table and I want to be able to count the number of entries or rows in the table. I've seen a lot of examples out there that use jQuery but they use the alert code for displaying the number. I just need a message above the table that would say 'there are # entries' or something that would update itself automatically with each new row.
I'm a new to all of this so it helps if you can be as detailed as possible.
Use jQuery:
var rows = $('tr').length;
I am new to the DataTables plugin,
How does it determine the number of columns to display?
Based on the HTML table? or based on the DataSource?
Or is it some combination of the two ?
Can I have columns in the DataSource that are not rendered as columns?
(but are used for example as a tooltip on another column) ?
How does it determine the number of columns to display?
The answer really depends on how you configure your table (keep reading to see what I mean).
Based on the HTML table? or based on the DataSource? Or is it some combination of the two ?
If you create a DOM based HTML table with all of your data already in it, then you can see from the zero configuration example that it will just display all of your columns that are provided.
Can I have columns in the DataSource that are not rendered as columns? (but are used for example as a tooltip on another column) ?
You can further configure the table to hide certain columns using the bVisible parameter in the aoColumnDefs or aoColumns settings for the table configuration. See this example for how to hide columns.
You can then use mrender to render a column in a particular way.
Say your data had two columns, ID and Name and you wanted to have Name be displayed but only show the ID as a tooltip when the user mouses over the Name cell. In your aoColumns object, set bVisible to false for the ID column and set mrender for the Name column as follows:
"mrender": function(data, type, full) {
return '<span title="' + full.ID + '">' + data + '</span>';
}
Note that if you're using a data source other than the data embedded in the DOM at load (such as AJAX) you're going to probably want to also specify the mdata parameter for each aoColumns definition, as can be seen in this example.
Best of luck!