Enkeled Kanaj Posted August 13 Share Posted August 13 HI , Managed to create a property control which shows KPIs on the same visualization from different tables the script changes the vis.ColorAxis.Expression = "<[NRCellDU]>" and needs to include the "Line by" and "table" Which are the codes for respective "Line by" and "Data table" alike the below one for "Color By" vis.ColorAxis.Expression = "<[NRCellDU]>" from Spotfire.Dxp.Application.Visuals import * from Spotfire.Dxp.Application.Visuals import HtmlTextArea kpi = Document.Properties["KPINRCELLDU"] vis = vis.As[Visualization]() if kpi == "NR NSA Leg Setup Success Rate (gNB)" or kpi == "NR NSA Leg Abnormal Release Rate (gNB)" \ or kpi == "EN-DC SCG PSCell change Success Rate - Intra gNB"\ or kpi == "EN-DC SCG PSCell change Success Rate - Inter gNB" or kpi == "NR Availability"\ or kpi == "NR DL MAC Volume (SA & NSA)" or kpi == "NR UL MAC Volume (SA & NSA)"\ or kpi == "Maximum DL MAC Throughput per NRCellDU (SA and NSA)"\ or kpi == "NR DL MAC UE Throughput (SA & NSA)"\ or kpi == "UL UE Throughput (SA & NSA)"\ or kpi == "Maximum UL MAC Throughput per NRCellDU (SA and NSA)": vis.ColorAxis.Expression = "<[NRCellDU]>" elif kpi == "LTE EN-DC DL PDCP UE Throughput"\ or kpi == "NR NSA Session Setup Success Rate (eNB)"\ or kpi == "NR NSA Session Abnormal Release Rate (eNB)"\ or Dkpi == "LTE EN-DC DL PDCP Volume"\ or kpi == "LTE EN-DC Average Split Bearers per Cell"\ or kpi == "LTE EN-DC UL PDCP UE Throughput"\ or kpi == "Differentiated Intra-Frequency Cell Mobility Success Rate in LTE (EN-DC)"\ or kpi == "Differentiated Inter-Frequency Cell Mobility Success Rate in LTE (EN-DC)"\ or Dkpi == "NR NSA Leg Setup Success Rate (eNB)": vis.ColorAxis.Expression = "<[EUtranCell]>" Link to comment Share on other sites More sharing options...
Solution Gaia Paolini Posted August 13 Solution Share Posted August 13 I am assuming the column names are the same in the different tables. Something like this: #set the table for the input vis (visualization) from table_name (string) vis = vis.As[Visualization]() vis.Data.DataTableReference = Document.Data.Tables.Item[table_name] #set the line by for vis vis.LineByAxis.Expression = "<[mycolumn]>" Link to comment Share on other sites More sharing options...
Enkeled Kanaj Posted August 13 Author Share Posted August 13 Hi @Gaia Paolini thank you for your solution but there is something small error that we can fix the first table is known maybe from the input parameter vis from script parameters how to define the second? Traceback (most recent call last): File "<string>", line 32, in <module> NameError: name 'DC_E_ERBS_EUTRANCELLFDD_DAY_NR' is not defined IronPython.Runtime.UnboundNameException: name 'DC_E_ERBS_EUTRANCELLFDD_DAY_NR' is not defined at IronPython.Runtime.Operations.PythonOps.GetVariable(CodeContext context, String name, Boolean isGlobal, Boolean lightThrow) at IronPython.Compiler.LookupGlobalInstruction.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) at Spotfire.Dxp.Application.IronPython27.IronPythonScriptEngine.ExecuteForDebugging(String scriptCode, Dictionary`2 scope, Stream outputStream) Link to comment Share on other sites More sharing options...
Olivier Keugue Tadaa Posted August 13 Share Posted August 13 Hi Enkeled, try this vis.Data.DataTableReference = Document.Data.Tables.Item["DC_E_ERBS_EUTRANCELLFDD_DAY_NR"] Link to comment Share on other sites More sharing options...
Gaia Paolini Posted August 13 Share Posted August 13 I don't understand your question. You are looking to set the data table and the line by programmatically on a visualization. You need to input the visualization, the name of the data table and the name of the column you want to define the line by. Link to comment Share on other sites More sharing options...
Enkeled Kanaj Posted August 13 Author Share Posted August 13 HI @Gaia Paolini and @Olivier Keugue Tadaa Perfect solved. Name needed as string as Olivier said "DC_E_NR_NRCELLDU_DAY" So I use only one property control with column selection from different tables and show them to the same chart. thanks both, Olivier help with the first part even though I made a little different approach but the same idea. from Spotfire.Dxp.Application.Visuals import * from Spotfire.Dxp.Application.Visuals import HtmlTextArea kpi = Document.Properties["KPINRCELLDU"] vis = vis.As[Visualization]() if kpi == "NR NSA Leg Setup Success Rate (gNB)" or kpi == "NR NSA Leg Abnormal Release Rate (gNB)" \ or kpi == "EN-DC SCG PSCell change Success Rate - Intra gNB"\ or kpi == "EN-DC SCG PSCell change Success Rate - Inter gNB" or kpi == "NR Availability"\ or kpi == "NR DL MAC Volume (SA & NSA)" or kpi == "NR UL MAC Volume (SA & NSA)"\ or kpi == "Maximum DL MAC Throughput per NRCellDU (SA and NSA)"\ or kpi == "NR DL MAC UE Throughput (SA & NSA)"\ or kpi == "UL UE Throughput (SA & NSA)"\ or kpi == "Maximum UL MAC Throughput per NRCellDU (SA and NSA)": vis.Data.DataTableReference = Document.Data.Tables.Item["DC_E_NR_NRCELLDU_DAY"] vis.LineByAxis.Expression = "<[NR_NAME]>" vis.ColorAxis.Expression = "<[NRCellDU]>" elif kpi == "LTE EN-DC DL PDCP UE Throughput"\ or kpi == "NR NSA Session Setup Success Rate (eNB)"\ or kpi == "NR NSA Session Abnormal Release Rate (eNB)"\ or Dkpi == "LTE EN-DC DL PDCP Volume"\ or kpi == "LTE EN-DC Average Split Bearers per Cell"\ or kpi == "LTE EN-DC UL PDCP UE Throughput"\ or kpi == "Differentiated Intra-Frequency Cell Mobility Success Rate in LTE (EN-DC)"\ or kpi == "Differentiated Inter-Frequency Cell Mobility Success Rate in LTE (EN-DC)"\ or kpi == "NR NSA Leg Setup Success Rate (eNB)": vis.Data.DataTableReference = Document.Data.Tables.Item["DC_E_ERBS_EUTRANCELLFDD_DAY (NR)"] vis.LineByAxis.Expression = "<[ERBS]>" vis.ColorAxis.Expression = "<[EUtranCellFDD]>" Link to comment Share on other sites More sharing options...
Enkeled Kanaj Posted August 14 Author Share Posted August 14 (edited) Hi @Gaia Paolini What is the syntax for the following when we have to add two dimensions like date and hour to xaxis or two columns to yaxis? vis.XAxis.Expression = "<Date>" vis.YAxis.Expression = "Sum(Sales)" Edited August 14 by Enkeled Kanaj Link to comment Share on other sites More sharing options...
Olivier Keugue Tadaa Posted August 14 Share Posted August 14 Hi Enkeled, you can use NEST like this 👇 vis.XAxis.Expression = "<[Date] NEST [HOUR]>" Link to comment Share on other sites More sharing options...
Enkeled Kanaj Posted August 14 Author Share Posted August 14 3 hours ago, Olivier Keugue Tadaa said: Hi Enkeled, you can use NEST like this 👇 vis.XAxis.Expression = "<[Date] NEST [HOUR]>" yes exactly, I saw the custom expression from a random graph and it was like that <BinByDateTime([DATE],"Year.Month.DayOfMonth",2) NEST [HOUR]> Link to comment Share on other sites More sharing options...
Enkeled Kanaj Posted August 29 Author Share Posted August 29 Hi @Gaia Paolini and @Olivier Keugue Tadaa I want to simplify a little bit the python script because I am lazy to write all KPI names but need to make if the value comes from the first box then execute and if from the second list box then execute. kpi = Document.Properties["KPINRCELLDU"] vis = vis.As[Visualization]() if kpi == "NR NSA Leg Setup Success Rate (gNB)" or kpi == "NR NSA Leg Abnormal Release Rate (gNB)" \ or kpi == "EN-DC SCG PSCell change Success Rate - Intra gNB"\ or kpi == "EN-DC SCG PSCell change Success Rate - Inter gNB" or kpi..... how to do if kpi in list box 1 Link to comment Share on other sites More sharing options...
Enkeled Kanaj Posted August 29 Author Share Posted August 29 Hi @Gaia Paolini and @Olivier Keugue Tadaa I did it with chatgpt. it was great from Spotfire.Dxp.Application.Visuals import * from Spotfire.Dxp.Application.Visuals import HtmlTextArea from Spotfire.Dxp.Data import DataTable kpi = Document.Properties["KPINRCELLDU"] vis = vis.As[Visualization]() # Step 1: Define the names of the tables from which you want to list columns table_name_1 = "DC_E_NR_NRCELLDU_RAW" # Replace with the actual first table name table_name_2 = "DC_E_ERBS_EUTRANCELLFDD_RAW (NR)" # Replace with the actual second table name # Step 2: Access the data tables by their names data_table_1 = Document.Data.Tables[table_name_1] data_table_2 = Document.Data.Tables[table_name_2] # Step 3: Create lists to hold the column names for each table column_names_1 = [] column_names_2 = [] # Step 4: Iterate over the columns in the first table and append their names to the first list for column in data_table_1.Columns: column_names_1.append(column.Name) # Step 5: Iterate over the columns in the second table and append their names to the second list for column in data_table_2.Columns: column_names_2.append(column.Name) if kpi in column_names_1: vis.Data.DataTableReference = Document.Data.Tables.Item["DC_E_NR_NRCELLDU_RAW"] vis.LineByAxis.Expression = "<[NR_NAME]>" vis.ColorAxis.Expression = "<[NRCellDU]>" elif kpi in column_names_2: vis.Data.DataTableReference = Document.Data.Tables.Item["DC_E_ERBS_EUTRANCELLFDD_RAW (NR)"] vis.LineByAxis.Expression = "<[ERBS]>" vis.ColorAxis.Expression = "<[EUtranCellFDD]>" 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now