I've written a function to create tables with different column setups and different data based on the parameters I send it. That all works fine.
My problem is that I can't get the setColumnLayout function to work when I want to reconfigure the existing table with new data and column settings. I know that the column settings are correct because they work for table creation.
The code, table.clearData(); , in the top section works normally.
I'm also unable to get the destroy function to work. As far as I could tell that is for Tabulator 3.0.
I am using Mac Chrome 76 and Tabulator 4.3.
Any help letting me know what I'm doing wrong would be apreciated.
Thanks, Mike
function createTable (tabledata,SelectedColumnSettings){
$("#clear").click(function(){
table.clearData();
var columnSettings = [
{title:"id", field:"id", visible:false},
{title:"Company", field:"Company Name", sorter:"string"},
{title:"Name", field:"Name", sorter:"string"},
{title:"Word Count Rate", field:"Word Count Rate", sorter:"number", align:"center"},
{title:"Hourly Rate", field:"Hourly Rate", sorter:"number", align:"center"},
{title:"Resourced", field:"Resourced", sorter:"number", align:"center"},
{title:"Language Source", field:"Language Source", sorter:"string"},
{title:"Profile Picture", field:"Profile Picture", align:"center"},
{title:"Completed Projects", field:"Completed Projects", sorter:"number", align:"center"}];
// var columnSettings=getColumnSettings("Contacts");
table.setColumnLayout(columnSettings);
});
var columnSettings=getColumnSettings(SelectedColumnSettings); // get the settings for the selected list
var table = new Tabulator("#example-table", {
height:600, // set height of table to enable virtual DOM
resizableColumns:false, // this option takes a boolean value (default = true)
data:tabledata, //load initial data into table
layout:"fitDataFill", //fit columns to width of table (optional)
columns: columnSettings, //Define Table Columns. Sets columns for the different lists projects, contacts....
});
}; // end create table
I'm not getting any errors.
Use Set Column
var columnSettings = [
{title:"id", field:"id", visible:false},
{title:"Company", field:"Company Name", sorter:"string"},
{title:"Name", field:"Name", sorter:"string"},
{title:"Word Count Rate", field:"Word Count Rate", sorter:"number", align:"center"},
{title:"Hourly Rate", field:"Hourly Rate", sorter:"number", align:"center"},
{title:"Resourced", field:"Resourced", sorter:"number", align:"center"},
{title:"Language Source", field:"Language Source", sorter:"string"},
{title:"Profile Picture", field:"Profile Picture", align:"center"},
{title:"Completed Projects", field:"Completed Projects", sorter:"number", align:"center"}];
// var columnSettings=getColumnSettings("Contacts");
table.setColumn(columnSettings);
setColumnLayout needs to be done in conjunction with getColumnLayout. Not sure where SelectedColumnSettings is coming from. Also getColumnSettings is a property of a table and I do see it being called that way:
var columnSettings=getColumnSettings(SelectedColumnSettings);
Related
I have a Power BI Chart
And I have databases
And I have Queries - example of code:
= (table as table) => let
apikey = "apikey",
endpoint = "endpoint",
inputTable = Table.TransformColumnTypes(table,{{"Timestamp", type text},{"Value", type number}}),
jsontext = Text.FromBinary(Json.FromValue(inputTable)),
jsonbody = "{ ""Granularity"": ""microsecond"", ""Sensitivity"": 95, ""Series"": "& jsontext &" }",
bytesbody = Text.ToBinary(jsonbody),
headers = [#"Content-Type" = "application/json", #"Ocp-Apim-Subscription-Key" = apikey],
bytesresp = Web.Contents(endpoint, [Headers=headers, Content=bytesbody, ManualStatusHandling={400}]),
jsonresp = Json.Document(bytesresp),
respTable = Table.FromColumns({
Table.Column(inputTable, "Timestamp")
,Table.Column(inputTable, "Value")
, Record.Field(jsonresp, "IsAnomaly") as list
, Record.Field(jsonresp, "ExpectedValues") as list
, Record.Field(jsonresp, "UpperMargins")as list
, Record.Field(jsonresp, "LowerMargins") as list
, Record.Field(jsonresp, "IsPositiveAnomaly") as list
, Record.Field(jsonresp, "IsNegativeAnomaly") as list
}, {"Timestamp", "Value", "IsAnomaly", "ExpectedValues", "UpperMargin", "LowerMargin", "IsPositiveAnomaly", "IsNegativeAnomaly"}
),
respTable1 = Table.AddColumn(respTable , "UpperMargins", (row) => row[ExpectedValues] + row[UpperMargin]),
respTable2 = Table.AddColumn(respTable1 , "LowerMargins", (row) => row[ExpectedValues] - row[LowerMargin]),
respTable3 = Table.RemoveColumns(respTable2, "UpperMargin"),
respTable4 = Table.RemoveColumns(respTable3, "LowerMargin"),
results = Table.TransformColumnTypes(
respTable4,
{{"Timestamp", type datetime}, {"Value", type number}, {"IsAnomaly", type logical}, {"IsPositiveAnomaly", type logical}, {"IsNegativeAnomaly", type logical},
{"ExpectedValues", type number}, {"UpperMargins", type number}, {"LowerMargins", type number}}
)
in results
When I select database and invoking it everything works
But when I am publishing my chart from Desktop to web and trying to refresh database, I have this error:
Processing error: [Unable to combine data] Section1/Invoked Function/Source references other
queries or steps, so it may not directly access a data source. Please rebuild this data combination.
Cluster URI: WABI-WEST-EUROPE-E-PRIMARY-redirect.analysis.windows.net
Activity ID: d304e6c7-e1d6-4ba3-bbb2-bf19bf2095be
Request ID: 96e790c5-c772-1c66-cceb-792e601fc416
Time: 2022-04-20 05:54:53Z
I am using Azure Anomaly Detector
I have a list of elemental impurities in power query which I wish to filter according to whether or not they exist on another list known as the prop65 list.
The screenshot below shows a simplified example of what I am trying to achieve.
I appreciate that using formulas However I don't know how to achieve this using a Power query solution. If anyone know how to achieve this it would be appreciated.
Data shown:
Aluminium 33.885
Antimony 0.6777
Arsenic 3.5064
Barium 2.259
Boron 1.3554
Bromoform 0.555
Cadmium 3.18895
Chromium 0.33885
Cobalt 1.1295
Copper 0.4518
Indium 0.4518
Simplified Prop65 List
Arsenic
Bromoform
Cadmium
Furan
Lead
Nafenopin
Here is one way to do that:
Read in the two tables
Do an Inner Join
let
//get original data
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
data = Table.TransformColumnTypes(Source,{{"Impurity", type text}, {"Amount (ppm)", type number}}),
//get Filter
Source2 = Excel.CurrentWorkbook(){[Name="Prop65"]}[Content],
filter = Table.TransformColumnTypes(Source2,{"Simplified Prop65 List", Text.Type}),
//Join them
filteredData = Table.Join(data,"Impurity", filter, "Simplified Prop65 List",JoinKind.Inner),
//Remove unneeded column
#"Removed Columns" = Table.RemoveColumns(filteredData,{"Simplified Prop65 List"})
in
#"Removed Columns"
Another method would be a filter (Table.SelectRows) method, but it may be slower with a large dataset. At least, in a single instance where I had an opportunity to compare, the Table.Join method was faster on a 100,000 row data set.
let
//get original data
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
data = Table.TransformColumnTypes(Source,{{"Impurity", type text}, {"Amount (ppm)", type number}}),
//get Filter
Source2 = Excel.CurrentWorkbook(){[Name="Prop65"]}[Content],
filter = Table.TransformColumnTypes(Source2,{"Simplified Prop65 List", Text.Type})[#"Simplified Prop65 List"],
//filter the rows
filteredData = Table.SelectRows(data, each List.Contains(filter,[Impurity]))
in
filteredData
I am using below query but it is not extracting defects which is linked to Test Steps of Test Cases.
So all the defects which are linked to test steps are not coming out.
SELECT Distinct BUG.BG_BUG_ID as "Defect ID", BUG.BG_DETECTED_BY as "Detected By", BUG.BG_SUMMARY as "Defect Name", BUG.BG_USER_03 as "Application", BUG.BG_USER_01 as "Category", LINK.LN_ENTITY_TYPE as "Type", TEST.TS_TEST_ID as "Test ID", TEST.TS_NAME as "Test Name", TEST.TS_USER_03 as "Test Category"
FROM LINK, BUG, TEST,STEP Where LINK.LN_BUG_ID = BUG.BG_BUG_ID AND LINK.LN_ENTITY_ID = TS_TEST_ID --AND BUG.BG_STATUS in ('Closed', 'Canceled', 'Duplicate') AND BUG.BG_DETECTED_IN_RCYC in (Select RELEASE_CYCLES.RCYC_ID from RELEASE_CYCLES where RELEASE_CYCLES.RCYC_NAME IN ('UAT - 3.1 MVA'))
Order by BUG.BG_BUG_ID
I am fairly new to DAX and to SSAS-Tabular, so I hope that you'll forgive any ignorance.
We have an SSAS-Tabular cube and we're using it in Excel to see the data (pivot table). Is there a way for me to view the DAX behind a measure in Excel?
Thanks,
Eli
In Excel, go to the 'Data' tab, click on 'New Query', select 'from Database', select 'from SQL Server Analysis Services database'.
Put in the name of the server, and the name of the database (name of the cube).
Click the dropdown next to "MDX or DAX query (optional)".
Add the following query (note that this is DMX, not MDX or DAX, but it will work - note that if you don't edit the catalog name to match your cube, it won't return any data):
SELECT
[MEASUREGROUP_NAME] AS [Table Name],
[MEASURE_CAPTION] AS [Measure Name],
[DESCRIPTION] AS [Measure Description],
[EXPRESSION] AS [Measure Logic]
FROM
$SYSTEM.MDSCHEMA_MEASURES
WHERE
[CUBE_NAME] ='Model'
AND
[MEASURE_IS_VISIBLE]
AND
[CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY
[MEASUREGROUP_NAME]
Click "Load".
You now have a page in the spreadsheet that functions as your data dictionary for measures. You can do the same thing, adding queries for dimenions with this code:
SELECT
[DIMENSION_UNIQUE_NAME] AS [Table Name],
HIERARCHY_CAPTION AS [Column Name],
[DESCRIPTION] AS [Column Description]
FROM
$system.MDSchema_hierarchies
WHERE
[CUBE_NAME] = 'Model'
AND
[HIERARCHY_ORIGIN] = 2
AND
[HIERARCHY_IS_VISIBLE]
AND
[CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY
[DIMENSION_UNIQUE_NAME]
And for tables, this code:
SELECT
[DIMENSION_CAPTION] AS [Table Name],
[DESCRIPTION] AS [Table Description]
FROM
$system.MDSchema_Dimensions
WHERE
[CUBE_NAME] ='Model'
AND
[DIMENSION_CAPTION] <> 'Measures'
AND
[CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY
[DIMENSION_CAPTION]
And for hierarchies, this code:
SELECT
[DIMENSION_UNIQUE_NAME] AS [Table Name],
[HIERARCHY_CAPTION] AS [Hierarchy Name],
[DESCRIPTION] AS [Hierarchy Description]
FROM
$system.MDSchema_hierarchies
WHERE
[CUBE_NAME] = 'Model'
AND
[HIERARCHY_ORIGIN] = 1
AND
[CATALOG_NAME] = '<enter name of your cube here>'
ORDER BY
[DIMENSION_UNIQUE_NAME]
If you edit the properties for these queries (use the 'Connections' button on the data tab), you can set this sheet to refresh every time the worksheet is opened (similar to how you probably have your pivot table connections set up), and now you have data dictionary tabs that automatically reflect the most current cube design. Hope this helps!
I want to execute a delete query via openJPA and mysql.
This mysql statement works fine:
delete from GENERIC
where PARENT_ID not in (select g2.ID from (select * from GENERIC) g2);
The basic element are a table GENERIC with columns ID and PARENT_ID
Mapping the GENERIC table to GenericEntity class, ID column to id member (of that class) and PARENT_ID column to parentId member, I tried this simple test:
entityManager.createQuery("delete from GenericEntity g1 where " +
"g1.parentId not in " +
"(select g2.id from (select * from GenericEntity) g2)"
).executeUpdate();
And I get this error:
org.apache.openjpa.persistence.ArgumentException: "Encountered "g1 .
parentId not in ( select g2 . id from (" at character 36, but
expected: ["(", "*", "+", ",", "-", ".", "/", ":", "<", "<=", "<>",
"=", ">", ">=", "?", "ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG",
"BETWEEN", "BOTH", "BY", "CASE", "CLASS", "COALESCE", "CONCAT",
"COUNT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP",
"DELETE", "DESC", "DISTINCT", "ELSE", "EMPTY", "END", "ENTRY",
"ESCAPE", "EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN", "INDEX",
"INNER", "IS", "JOIN", "KEY", "LEADING", "LEFT", "LENGTH", "LIKE",
"LOCATE", "LOWER", "MAX", "MEMBER", "MIN", "MOD", "NEW", "NOT",
"NULL", "NULLIF", "OBJECT", "OF", "OR", "ORDER", "OUTER", "SELECT",
"SET", "SIZE", "SOME", "SQRT", "SUBSTRING", "SUM", "THEN", "TRAILING",
"TRIM", "TYPE", "UPDATE", "UPPER", "VALUE", "WHEN", "WHERE",
, , , ,
, , ,
, ]." while parsing JPQL "delete from
GenericEntity g1 where g1.parentId not in (select g2.id from (select *
from GenericEntity) g2)". See nested stack trace for original parse
error.
I tried different variants, also replaced the delete by an update (to set a 'deleted' flag instead), but it seems to be a general problem to modify a table when this very table is used in the where clause.
I'd appreciate very much a hint, how to continue or a link to any helpful material.
Thank you very much in advance!
After a lot of research, I have found a solution. It works fine to separate the select from the delete query and pass the list of IDs as a parameter to the delete statement:
List<Integer> idList = entityManager
.createQuery("select g.id from GenericEntity g",Integer.class)
.getResultList();
entityManager
.createQuery("delete from GenericEntity g where g.parentId not in (:idList)")
.setParameter("idList", idList)
.executeUpdate();