Variables are the in-report writable state. They answer the question "which row did the user just click?" — the viewer mutates them; expressions read them. Crucially, nothing inside the viewer mutates parameters. Drills, cell clicks, chart clicks all write to variables. Parameters only change via the parameter panel’s Apply button.
A variable has a scope: global variables live on the report and are writable from anywhere; component variables are declared on a specific component and are only writable from within that component’s subtree. Outside the subtree, reads fall through to the global bucket with the same name (or null).
1 · Global variable + drill-through → conditional visibility
The classic pattern. Clicking a row writes the row into a global variable; a downstream component reads it and toggles visibility.
Drill-through → Variable → Visibility
Orders — click a row to reveal the detail panel
The table’s Drill-through Variable is set to `selectedOrder`. Clicking a row writes the full row object into the variable; the detail panel below checks `!IsEmpty(Variables.selectedOrder)` in styles.visible to appear once a selection exists. Parameters never change from this interaction.
Order
Region
Product
Revenue
ORD-1000
East
Water Bottle
$689
ORD-1001
West
T-Shirt
$70
ORD-1002
East
T-Shirt
$60
ORD-1003
West
T-Shirt
$357
ORD-1004
West
Wireless Buds
$4,942
ORD-1005
West
Yoga Mat
$470
ORD-1006
East
Sneakers
$261
ORD-1007
South
Sneakers
$738
ORD-1008
West
Throw Pillow
$888
ORD-1009
North
Smart Watch
$1,392
ORD-1010
East
Jacket
$440
ORD-1011
West
Smart Watch
$5,073
ORD-1012
North
Water Bottle
$492
ORD-1013
South
Jeans
$949
ORD-1014
South
Sneakers
$413
ORD-1015
East
Jeans
$540
ORD-1016
West
T-Shirt
$584
ORD-1017
West
Desk Lamp
$812
ORD-1018
East
Water Bottle
$588
ORD-1019
South
Wireless Buds
$5,895
ORD-1020
East
T-Shirt
$936
ORD-1021
North
Throw Pillow
$296
ORD-1022
East
Throw Pillow
$779
ORD-1023
East
Yoga Mat
$432
ORD-1024
East
Candle Set
$71
ORD-1025
East
Wireless Buds
$3,080
ORD-1026
South
Running Shoes
$315
ORD-1027
East
Candle Set
$728
ORD-1028
West
Dumbbells
$689
ORD-1029
South
Jeans
$915
ORD-1030
East
Wireless Buds
$3,078
ORD-1031
North
Laptop Pro
$3,485
ORD-1032
South
Candle Set
$585
ORD-1033
South
Throw Pillow
$859
ORD-1034
South
USB Hub
$3,302
ORD-1035
South
Water Bottle
$477
ORD-1036
West
Smart Watch
$1,350
ORD-1037
East
Water Bottle
$451
ORD-1038
West
Dumbbells
$204
ORD-1039
North
Rug 5x8
$1,180
ORD-1040
East
Jeans
$1,188
ORD-1041
East
Desk Lamp
$697
ORD-1042
South
Jeans
$72
ORD-1043
West
Candle Set
$500
ORD-1044
North
Candle Set
$779
ORD-1045
East
Candle Set
$1,180
ORD-1046
North
Yoga Mat
$656
ORD-1047
West
T-Shirt
$186
ORD-1048
East
Jacket
$1,134
ORD-1049
South
Water Bottle
$760
ORD-1050
East
Sneakers
$303
ORD-1051
East
Candle Set
$122
ORD-1052
North
Desk Lamp
$228
ORD-1053
East
Water Bottle
$402
ORD-1054
South
Dumbbells
$1,060
ORD-1055
West
Yoga Mat
$526
ORD-1056
West
Yoga Mat
$256
ORD-1057
South
Jeans
$1,008
ORD-1058
West
Throw Pillow
$341
ORD-1059
South
Smart Watch
$3,780
ORD-1060
South
Jeans
$122
ORD-1061
West
T-Shirt
$1,292
ORD-1062
West
Laptop Pro
$3,729
ORD-1063
East
Running Shoes
$392
ORD-1064
South
Sneakers
$852
ORD-1065
East
Yoga Mat
$37
ORD-1066
East
Jacket
$960
ORD-1067
North
T-Shirt
$684
ORD-1068
North
USB Hub
$2,056
ORD-1069
South
Running Shoes
$714
ORD-1070
West
Rug 5x8
$1,037
ORD-1071
North
Water Bottle
$600
ORD-1072
East
Wireless Buds
$1,275
ORD-1073
West
Running Shoes
$216
ORD-1074
East
Desk Lamp
$489
ORD-1075
West
Smart Watch
$2,718
ORD-1076
North
Rug 5x8
$688
ORD-1077
South
Running Shoes
$90
ORD-1078
South
Sneakers
$1,501
ORD-1079
South
T-Shirt
$336
2 · Component-scoped variables
Two tables, same variable name, independent buckets. Click a row in one — the other is unaffected.
Component-scoped variable
Component-scoped variables
Each table below declares its own `localSelection` variable (scope = component). Drills in one table do NOT leak into the other — the scope walker only writes to the nearest enclosing declaration that knows the name.
North / Order
Product
Revenue
ORD-1009
Smart Watch
$1,392
ORD-1012
Water Bottle
$492
ORD-1021
Throw Pillow
$296
ORD-1031
Laptop Pro
$3,485
ORD-1039
Rug 5x8
$1,180
ORD-1044
Candle Set
$779
ORD-1046
Yoga Mat
$656
ORD-1052
Desk Lamp
$228
ORD-1067
T-Shirt
$684
ORD-1068
USB Hub
$2,056
ORD-1071
Water Bottle
$600
ORD-1076
Rug 5x8
$688
South / Order
Product
Revenue
ORD-1007
Sneakers
$738
ORD-1013
Jeans
$949
ORD-1014
Sneakers
$413
ORD-1019
Wireless Buds
$5,895
ORD-1026
Running Shoes
$315
ORD-1029
Jeans
$915
ORD-1032
Candle Set
$585
ORD-1033
Throw Pillow
$859
ORD-1034
USB Hub
$3,302
ORD-1035
Water Bottle
$477
ORD-1042
Jeans
$72
ORD-1049
Water Bottle
$760
ORD-1054
Dumbbells
$1,060
ORD-1057
Jeans
$1,008
ORD-1059
Smart Watch
$3,780
ORD-1060
Jeans
$122
ORD-1064
Sneakers
$852
ORD-1069
Running Shoes
$714
ORD-1077
Running Shoes
$90
ORD-1078
Sneakers
$1,501
ORD-1079
T-Shirt
$336
3 · Set-variable cell action (buttons / pills)
Cell items can set a variable to an arbitrary expression value. Use this for view-mode toggles or anything that is not a row selection.
Set-variable cell actions
Buttons that write to variables
The three rows in the first table are backed by a tiny `modes` datasource. Each row's Label column uses a `set-variable` cell-item that writes the row's key into `viewMode`. The main orders table below has a footer expression that reads `Variables.viewMode` via Switch() and shows the matching aggregate.
Click a mode to switch the footer aggregate
Current mode: revenue
Order
Region
Product
Units
Revenue
Cost
ORD-1000
East
Water Bottle
13
$689
$344
ORD-1001
West
T-Shirt
1
$70
$32
ORD-1002
East
T-Shirt
1
$60
$33
ORD-1003
West
T-Shirt
5
$357
$213
ORD-1004
West
Wireless Buds
14
$4,942
$2,311
ORD-1005
West
Yoga Mat
10
$470
$219
ORD-1006
East
Sneakers
3
$261
$165
ORD-1007
South
Sneakers
9
$738
$479
ORD-1008
West
Throw Pillow
16
$888
$546
ORD-1009
North
Smart Watch
4
$1,392
$684
ORD-1010
East
Jacket
8
$440
$254
ORD-1011
West
Smart Watch
15
$5,073
$2,624
ORD-1012
North
Water Bottle
12
$492
$264
ORD-1013
South
Jeans
13
$949
$472
ORD-1014
South
Sneakers
7
$413
$189
ORD-1015
East
Jeans
9
$540
$300
ORD-1016
West
T-Shirt
8
$584
$320
ORD-1017
West
Desk Lamp
14
$812
$498
ORD-1018
East
Water Bottle
14
$588
$338
ORD-1019
South
Wireless Buds
15
$5,895
$3,202
ORD-1020
East
T-Shirt
12
$936
$568
ORD-1021
North
Throw Pillow
7
$296
$149
ORD-1022
East
Throw Pillow
19
$779
$418
ORD-1023
East
Yoga Mat
12
$432
$259
ORD-1024
East
Candle Set
2
$71
$41
ORD-1025
East
Wireless Buds
11
$3,080
$1,972
ORD-1026
South
Running Shoes
7
$315
$176
ORD-1027
East
Candle Set
13
$728
$384
ORD-1028
West
Dumbbells
13
$689
$331
ORD-1029
South
Jeans
15
$915
$577
ORD-1030
East
Wireless Buds
9
$3,078
$1,704
ORD-1031
North
Laptop Pro
14
$3,485
$2,056
ORD-1032
South
Candle Set
13
$585
$296
ORD-1033
South
Throw Pillow
14
$859
$392
ORD-1034
South
USB Hub
13
$3,302
$2,013
ORD-1035
South
Water Bottle
9
$477
$262
ORD-1036
West
Smart Watch
5
$1,350
$770
ORD-1037
East
Water Bottle
12
$451
$267
ORD-1038
West
Dumbbells
4
$204
$132
ORD-1039
North
Rug 5x8
20
$1,180
$579
ORD-1040
East
Jeans
18
$1,188
$594
ORD-1041
East
Desk Lamp
17
$697
$390
ORD-1042
South
Jeans
1
$72
$43
ORD-1043
West
Candle Set
10
$500
$300
ORD-1044
North
Candle Set
19
$779
$426
ORD-1045
East
Candle Set
20
$1,180
$722
ORD-1046
North
Yoga Mat
16
$656
$355
ORD-1047
West
T-Shirt
3
$186
$98
ORD-1048
East
Jacket
18
$1,134
$714
ORD-1049
South
Water Bottle
20
$760
$353
ORD-1050
East
Sneakers
4
$303
$179
ORD-1051
East
Candle Set
2
$122
$68
ORD-1052
North
Desk Lamp
4
$228
$105
ORD-1053
East
Water Bottle
12
$402
$240
ORD-1054
South
Dumbbells
20
$1,060
$550
ORD-1055
West
Yoga Mat
11
$526
$300
ORD-1056
West
Yoga Mat
8
$256
$147
ORD-1057
South
Jeans
14
$1,008
$572
ORD-1058
West
Throw Pillow
9
$341
$180
ORD-1059
South
Smart Watch
14
$3,780
$1,864
ORD-1060
South
Jeans
2
$122
$76
ORD-1061
West
T-Shirt
19
$1,292
$623
ORD-1062
West
Laptop Pro
11
$3,729
$2,070
ORD-1063
East
Running Shoes
8
$392
$211
ORD-1064
South
Sneakers
12
$852
$508
ORD-1065
East
Yoga Mat
1
$37
$22
ORD-1066
East
Jacket
15
$960
$483
ORD-1067
North
T-Shirt
12
$684
$428
ORD-1068
North
USB Hub
8
$2,056
$1,123
ORD-1069
South
Running Shoes
14
$714
$443
ORD-1070
West
Rug 5x8
17
$1,037
$514
ORD-1071
North
Water Bottle
14
$600
$297
ORD-1072
East
Wireless Buds
5
$1,275
$584
ORD-1073
West
Running Shoes
6
$216
$121
ORD-1074
East
Desk Lamp
9
$489
$230
ORD-1075
West
Smart Watch
9
$2,718
$1,617
ORD-1076
North
Rug 5x8
16
$688
$399
ORD-1077
South
Running Shoes
2
$90
$45
ORD-1078
South
Sneakers
19
$1,501
$765
ORD-1079
South
T-Shirt
6
$336
$157
Total (revenue)
$83,831
Notes
Drill writes the whole row. If you only need one field, use a cell-item drill action with drillValueExpr, or just read the path (Variables.selectedOrder.id) downstream.
Scope resolution is bottom-up. A cell action writes to the nearest enclosing component that declares the variable name. If no component declares it, it falls back to the global bucket.
Default values are expressions.defaultValueExpression: "=Today()" seeds the variable on first render; explicit writes override it thereafter.
Host visibility.onDrillThrough(variableName, value) still fires as a pure notification — use it if the host app needs to react (analytics, navigation) in addition to the in-report variable write.