XLCubed Select / Deselect All
I had a request to create a select all deselect all button in XLCubed


After some deep thoughts I found the following solution
Step 1:
Create a table slicer:

Set your selection and initial value range
Set "Set initial value when" to "Available items change"
Edit your query:


The part:
"Union All
Select 'Dummy' + Cast(NewId() As VARCHAR(50))"
Is necessary to "tell" the slicer it has new data after each refresh.
Connect your table or grid to the slicer in the normal way:
"Select tParameters.*
From tParameters
Where tParameters.UserName In (@UserName)"
The source for the intial values in also a table

Query:
"Select Top (1) tParameters.UserName
From tParameters
Union
Select tParameters.UserName
From tParameters
Where Cast(1 As BIT) = @SelectAll"
This query returns the first row if @SelecAll = FALSE else you get all the rows.
On your parameters sheet add "=XL3RefreshObjects(B2,TRUE,TRUE,TRUE,TRUE,TRUE)" to cell B3

And finally lets create the button:
=XL3Link(XL3Address(A1),IF(Parameters!B1=FALSE,"SELECT ALL","DESELECT ALL"),3,XL3Address(Parameters!B1),NOT(Parameters!B1),XL3Address(Parameters!B2),TRUE)
Till Next Time
After some deep thoughts I found the following solution
Step 1:
Create a table slicer:
Set your selection and initial value range
Set "Set initial value when" to "Available items change"
Edit your query:
The part:
"Union All
Select 'Dummy' + Cast(NewId() As VARCHAR(50))"
Is necessary to "tell" the slicer it has new data after each refresh.
Connect your table or grid to the slicer in the normal way:
"Select tParameters.*
From tParameters
Where tParameters.UserName In (@UserName)"
The source for the intial values in also a table
Query:
"Select Top (1) tParameters.UserName
From tParameters
Union
Select tParameters.UserName
From tParameters
Where Cast(1 As BIT) = @SelectAll"
This query returns the first row if @SelecAll = FALSE else you get all the rows.
On your parameters sheet add "=XL3RefreshObjects(B2,TRUE,TRUE,TRUE,TRUE,TRUE)" to cell B3
And finally lets create the button:
=XL3Link(XL3Address(A1),IF(Parameters!B1=FALSE,"SELECT ALL","DESELECT ALL"),3,XL3Address(Parameters!B1),NOT(Parameters!B1),XL3Address(Parameters!B2),TRUE)
Till Next Time
Comments
Post a Comment