Input Parameters using BloX for What-If Analysis
Input Parameters using BloX for What-If Analysis This is an alternative to the paid or community Input Parameter plugins. This new BloX Input Parameter custom action: supports multiple levers (input parameters) with just one Apply button supports all widget types remembers previous selections even after refreshing/closing the dashboard loops through all widgets so dashboard designers do not have to specify widget IDs in the BloX code. Note: Be mindful of performance when considering this option as this will execute the BloX action on all widgets including those that the input parameters may not necessarily be relevant to. Input Parameter Implementation Instructions: Import the example dashboard attached below. Before importing the file, change the file extension from .txt to .dash. Make sure that you still have the Sample ECommerce Elasticube for this dashboard to properly display the data. Open the BloX Lever Configuration widget, then add the custom action given below to your Sisense environment. Go to the Actions tab, click the three-dot menu, then click Create Action. Copy the custom action code from below and paste it into your BloX custom action editor. Give this name for the action: ParameterSwap_V2_AllWidgets. You can also use a different name, but make sure the name of the action matches with the name referenced in the BloX code. Click Next, then Create. Click the Apply button to close the widget. Enter values to the levers and click Apply. The number on the widgets is now recalculated based on your input. There are three input parameters in this example. To add another input parameter: In the BloX code of the Lever Configuration widget, modify the number of input parameters in the BloX code under the paramsToModify parameter. For example, if you need 4 input parameters (levers), update the value to 4. On the left panel, add the additional swap_levers to the Values panel, i.e. swap_lever4, swap_lever5, etc. You can assign any arbitrary hard-coded number to these swap levers. To add the input box to the widget, copy one of the column elements then add it to the BloX code. Modify the id parameter to selectVal<lever number>, e.g. if this is the fourth lever, the id should be selectVal4. Similarly, modify the value parameter to match the swap_lever name you added in the previous step, e.g. [swap_lever4]. Update the title text as well and give it a meaningful description. Save the widget by clicking the Apply button. Add the additional levers to your widget formulas as needed so that they get recalculated when you enter the input values. Input Parameter BloX action: //initialize variables var swapParam = []; //create an array of swap_levers for (d = 0; d < payload.data.paramsToModify; d++) { swapParam[d] = "swap_lever" + (d + 1); } //loop through each of the specified widgets payload.widget.dashboard.widgets.$$widgets .forEach(function (widget) { //loop through each panel in the widget //exclude the filter panel (last panel) for (p = 0; p < widget.metadata.panels.length - 1; p++) { //loop through each item in the panel for (i = 0; i < widget.metadata.panels[p].items.length; i++) { //check if the panel item contains context (i.e. a formula) if (widget.metadata.panels[p].items[i].jaql.context != undefined) { var queryContext = widget.metadata.panels[p].items[i].jaql.context; //loop through each context in the item for (let [k, v] of Object.entries(queryContext)) { //loop through each swap_lever for (s = 0; s < swapParam.length; s++) { //check if the formula contains the swap_lever if (v.title == swapParam[s]) { var val = 'selectVal' + (s + 1); //update the formula with the swap_lever value that the user entered v.formula = payload.data[val]; } } } } } } //apply and save changes to the widget widget.changesMade('plugin-BloX', ['metadata']) //refresh the widget widget.refresh(); }) Resetting to Default Values The attached dashboard example includes a Reset button to reset the input parameters to pre-set default values. If you do not need this option, you can remove the second action from the BloX code, as shown in the highlighted part of the screenshot below. Instructions to implement the Reset button: Open the BloX Lever Configuration widget, then add the custom action given below to your Sisense environment. Go to the Actions tab, click the three-dot menu, then click Create Action. Copy the custom action code from below and paste it into your BloX custom action editor. Give this name for the action: ParameterSwap_V2_AllWidgets_Reset. You can also use a different name, but make sure the name of the action matches with the name referenced in the BloX code. Click Next, then Create. In the BloX code, update the defaultValues array with your required default values. See screenshot below for reference. There are three input parameters in this example, if you have more/less parameters, update the paramsToModify value to the correct number of parameters that you have. See screenshot below for reference. Click the Apply button to close the widget. Reset Input Parameter BloX action: //initialize variables var leverValues = payload.data.defaultValues; var swapParam = []; //create an array of swap_levers for (d = 0; d < payload.data.paramsToModify; d++) { swapParam[d] = "swap_lever" + (d + 1); } //loop through all widgets in the dashboard payload.widget.dashboard.widgets.$$widgets .forEach(function (widget) { //loop through each panel in the widget //exclude the filter panel (last panel) for (p = 0; p < widget.metadata.panels.length - 1; p++) { //loop through each item in the panel for (i = 0; i < widget.metadata.panels[p].items.length; i++) { //check if the panel item contains context (i.e. a formula) if (widget.metadata.panels[p].items[i].jaql.context != undefined) { var queryContext = widget.metadata.panels[p].items[i].jaql.context; //loop through each context in the item for (let [k, v] of Object.entries(queryContext)) { //loop through each swap_lever for (s = 0; s < swapParam.length; s++) { //check if the formula contains the swap_lever if (v.title == swapParam[s]) { var val = 'selectVal' + (s + 1); //update the formula with the default value v.formula = leverValues[s]; } } } } } } //apply and save changes to the widget widget.changesMade('plugin-BloX', ['metadata']) //refresh the widget widget.refresh(); }) We hope this is a helpful article and would love to hear about your experience in the comments!16KViews4likes12CommentsCONDITIONAL CASE SUM
Hi Sisense Community!! Please reference the attached workbook that I drafted in Excel. I am trying to draft a daily view by week, of each employee's time worked. This screenshot shows an example of actual hours worked by day by employee. I am trying to create a dynamic case statement for a metric that calculates the same way as is seen in K7 in the workbook. Essentially it would ready like this: SUM(TIME ON SUNDAY) + IF (TIME ON MONDAY = 0 THEN 0 ELSE TIME ON MONDAY) + IF(TIME ON TUESDAY = 0 THEN 0 ELSE TIME ON TUESDAY) + IF(TIME ON WEDNESDAY = 0 THEN 0 ELSE TIME ON WEDNESDAY) + IF(TIME ON THURSDAY = 0 THEN 0 ELSE TIME ON THURSDAY) + IF(TIME ON FRIDAY = 0 THEN 0 ELSE TIME ON FRIDAY) Any suggestions on how to get this case statement started through the first two lines? Many thanks in advance! -CarterSolved16KViews1like16CommentsInteractive Time Period Comparison with BloX & Custom Actions
Here is a use case on how to leverage BloX widgets in Sisense to create an interactive dashboard for comparing any KPI between two different time periods. This solution allows users to select two months (or any two time periods) and dynamically calculates the percentage change in the KPI between these selected months.11KViews3likes4CommentsDYNAMICALLY FORMATTED DATA LABELS
Does anyone have suggestions on how to do the following: Script the data labels so that they never overlap? I'm not sure if that's possible but I can hope! Add additional formatting around the data labels similar to the screenshot below where each data label is surrounded in a colored shape?Solved10KViews1like12CommentsUse of Conditions in BloX
I am attempting to use Conditions in a BloX widget. Unfortunately, the documentation for this feature is not very thorough and doesn't cover my use case. I am building a table. Each row has two columns, a label and a value. For each row in the table, I want to check the value and if it is below a certain amount, I want to hide the complete row. Basically, I want to set the style to "Display": "none" for that item in the container. In the attached snip, I want to hide the item that begins on line 41 because CountTotal2017 has a negative value. I have searched for documentation on using Conditions in BloX and pretty much everywhere it gives the same basic example of changing a text's color and changing which image to display. If anyone knows how to accomplish what I need, or can point me to more thorough documentation on the feature, I would greatly appreciate a reply. TIA.Solved9KViews0likes7CommentsGoal line in a bar/column chart, is it possible to take an user input to set the goal?
I have currently implemented the benchmark target line from https://www.binextlevel.com/post/add-target-benchmark-line-to-a-chart-in-sisense I was wondering if it's possible to have a user input using Blox to set that benchmark line instead of using a static number in a script. Or any other way other than using Blox? Thank you in advanceSolved7.4KViews0likes11CommentsHow to create custom action based on a BLOX dropdown filter (+Styling the filter)?
I'm currently using the Wiser Filter widget plugin to display some dropdown filters on a dashboard, but I would like to add some more involved filtering (where I potentially apply filters to two columns at once) using BLOX. I really like the styling of the Wiser Filter widget, and I think the default Blox dropdown filter styling, while practical, is very basic. I haven't found a way to style the dropdown box. Any guidance on where to start in that direction would be useful. My main issue, however is that I have some trouble getting the BLOX dropdown filter to work as I would want it to. Even the default template doesn't actually work for me to *filter*. It does display the list of filter values but the 'apply' button does nothing, even though I filled in the filter name in the script and that's also what the filter on the dashboard was called. Interestingly, the default template gives the snippet for the dropdown the id "data.filters[0].filterJaql.members[0]". If I check the documentation, that says the id attribute for a Dropdown must be 'selectVal'. I wasn't particularly interested in the default usecase for the dropdown so I used the 'selectVal' id and tried to create a custom action that reads out this value (+ a value from a tickybox) and applies filters that way. But there I run into the issue that the value available as 'selectVal' is an HTML Collection that the filters can't work with. It actually seems to be the entire list of values that *could* be filtered on, not the selected value. How do I get the actual selected value so I can use it in my script? The script of the custom action that showed to me that 'selectVal' was a strange collection (I know this doesn't actually set any filters yet): const filterText = payload.data.selectVal const filterTitle = payload.titleToFilter const filterDim = payload.dimToFilter console.log(selectVal); prism.activeDashboard.filters.update( { 'jaql': { 'dim': filterDim, 'title': filterTitle, 'filter': { 'members': [] }, 'explixit': true, 'multiSelection': true, 'datatype':'text' } }, { 'save': true, 'refresh': true } );Solved7.3KViews1like6CommentsTransposing Pivot Table
Current format ^ The format I want to achieve ^ Hi everyone, I am currently working on a project and the client wants the values to be displayed in rows, grouped by Country (as seen in the image above). However, the default in Sisense is to put the values in columns. Switching the rows and columns also does not seem to resolve this issue. I've attached the current format of the table I have in Sisense, as well as the desired format I am going for. Essentially, I want to recreate the format of the Tableau table in Sisense 🙂 Thank you and please let me know if anything was unclear.Solved7.1KViews0likes6Comments