I have a parameter 'Catégorie de vente' which contains two values 'Déchets and No Sans déchets', the problem is that when I click on select all, it just selects me the first value 'Déchets ' the other not.
Here is the parameter
And here is the request
Any heeelp pleaseee!!!!
Why selecting all does not work
Related
I'd like to update a column with just the domain part of an email address.
update
users
set
email_base_domain = regexp_match(email, '(\w+\.\w+)$')
However, regexp_match returns a text[]. If email is example#foo.com the above sets email_base_domain to {foo.com}. I would like foo.com.
How do I get just the first element as text from the text[] returned by regexp_match?
Add a set of parentheses to group what you want to extract. For example:
SELECT regexp_matches(email, '(\w+)\.\w+$')
FROM users
will return {foo}, while
SELECT regexp_matches(email, '\w+\.(\w+)$')
FROM users
will return '{com}'.
Once you have a text array you can use regular array indexing to extract values from the returned text array. For example:
SELECT (regexp_matches(email, '(\w+)\.\w+$'))[1]
FROM users
returns 'foo' and
SELECT (regexp_matches(email, '\w+\.(\w+)$'))[1]
FROM users
returns 'com'.
db<>fiddle with other alternatives here
I'm trying to pass a string parameter obtained by another query to another query in the same dashboard but when I use the parameter no results was selected. What is the proper syntax or where is the problem.
I'm beginner in pentaho biserver-CE. I use version 6.1. with JDBC connection to SQL Server 2016 SP1.
Now I'm making a sales dashboard from invoices and i want to make a dynamic filter by the time units (which works fine) and by the country shortcuts (which didn't work). If i pass shortcut of some country directly with quotes it works fine but when I replace it by the parameter it doesn't select nothing (Also in CDA preview). When I made some reports in Jasper i used exclamation inside of the parameter to pass quoted value but here I didn't find anything like this for Pentaho.
select top 10
invrow.item as ITEM,
invrow.agent as AGENT,
sum(invrow.qt) as MEASURE,
sum(invrow.val) as VALUE
from invrow
left join invhead on invrow.type = invhead.type
and invrow.nr = invhead.nr
left join art on invrow.item = art.item
where left(invhead.date,4) = ${year}
and invhead.country like ${Country}
group by invrow.item, invrow.agent, invhead.country
order by MEASURE DESC
parameter ${Country} was acquired by another query by the same field. There is a query to gain the parameter:
select distinct
invhead.country
from
invhead
where
left(invhead.date,4) = ${year}
The original query shows nothing but when I Replace parameter ${Country} by for example 'UK' like this.
It works fine:
select top 10
invrow.item as ITEM,
invrow.agent as AGENT,
sum(invrow.qt) as MEASURE,
sum(invrow.val) as VALUE
from invrow
left join invhead on invrow.type = invhead.type
and invrow.nr = invhead.nr
left join art on invrow.item = art.item
where left(invhead.date,4) = ${year}
and invhead.country like 'UK'
group by invrow.item, invrow.agent, invhead.country
order by MEASURE DESC
Now when I use parameter I have nothing in the select list but there are rows, which should be selected.
The syntax is correct, but that way of passing parameters only works for single valued parameters.
To pass an array of parameters, as you seem to be trying, you need to pass the parameter as right hand side of a in operator,
(...)
and invhead.country in ( ${Country} )
(...)
and set the parameter to be of type StringArray.
This stored procedure beneath fills up my Projectphase parameter. So as you can see, the user first has to select #PurchaseOrder, which will then fill up the Projectphase Parameter.
CREATE PROCEDURE [dbo].[USP_GetProjectPhase]
#PurchaseOrder INT
AS
SELECT
pp.ProjectPhaseID, pp.Phase
FROM
ProjectPhase pp
WHERE
#PurchaseOrder = pp.PurchaseOrderId
Now when the user selects a PurchaseOrder that indeed has Projectphases, everything goes well. The issue situates itself in the purchaseorders that don't have a ProjectPhase.
The query that is used for my dataset shown on the report has the following line in the WHERE clause. It's a multivalue parameter cause the user needs to be able to select multiple Projectphases.
WHERE
reg.ProjectPhaseId IN (SELECT Value
FROM fnLocal_CmnParseList(#Phase,','))
I've tried UNIONS with NULL, NULL. I've tried stuff with ISNULL but I can't seem to be getting the query to execute when #ProjectPhase is NULL.
Some help would be greatly appreciated cause I've been cracking my head on this for too long now. Thanks
Finally found the answer:
[dbo].[USP_GetProjectPhase] #PurchaseOrder INT
AS
SELECT -1 AS 'ProjectPhaseID'
,'No Filter' AS 'Phase'
UNION
SELECT pp.ProjectPhaseID
,pp.Phase
FROM ProjectPhase pp
WHERE #PurchaseOrder = pp.PurchaseOrderId
In my query I changed the WHERE clause to:
WHERE (reg.ProjectPhaseId IN (SELECT Value FROM fnLocal_CmnParseList(#Phase,',')) OR #Phase = '-1')
I have 3 simple parameters, all which are text, and allow for multiple values as well as blank values. There are no available values or default values, as I want the users to type the value themselves. When leaving all parameters blank, no data is shown, because there are no blank values. However, I want to show all data when there is no value entered for the parameter. How can I do this?
This is what the query looks like right now
SELECT [PROGRAMNO]
,[ACCTNO]
,[CLAIMNO]
,[TOTALCHARGES]
,[TOTALPAYMENT]
,[TYPE]
FROM DATALINE
WHERE PROGRAMNO IN (#PROGRAMNO)
AND ACCTNO IN (#ACCTNO)
AND CLAIMNO IN (#CLAIMNO)
You can add an OR to allow for the NULL (or blank) value for each condition - depending on which you have allowed in the parameter.
WHERE (PROGRAMNO IN (#PROGRAMNO) OR #PROGRAMNO is null)
AND (ACCTNO IN (#ACCTNO) OR #ACCTNO IS NULL)
AND (CLAIMNO IN (#CLAIMNO) OR #CLAIMNO IS NULL)
or if you allow blank values instead:
WHERE (PROGRAMNO IN (#PROGRAMNO) OR #PROGRAMNO = '' )
AND (ACCTNO IN (#ACCTNO) OR #ACCTNO = '' )
AND (CLAIMNO IN (#CLAIMNO) OR #CLAIMNO = '' )
Multi-value parameters do not allow blank input. So you will need to add an item to your dropdown list that represents the blank value. If you are manually specifying the available values you would simply add this to the list. The value would be blank and the label could be something like "Blank" or "N/A". If you are using a query to populate the available values you will need to UNION this blank value to the other results. Either way, you'll also need to account for this in your WHERE clause in the main dataset as Hannover Fist pointed out.
Good day. I would like to know why a Parameter Request pops up when executing a query. I have a form with 2 comboboxes where the 2nd one depends on the value in the 1st one. I do know how to do this when it involves 2 tables. I am having trouble when there is a many to many relationship.
Table 1: name - Supply_Sources, fields - Source_ID(pk), SupplySourceName
Table 2: name - Warehouse_Locations, fields - WLocation_ID(pk), Location_Name
Table 3 (junction): name - SupplySource_WarehouseLocation, fields - Supply_Source_ID(pk), Location_In_ID(pk)
On my form frmInventoryReceivedInput I have cboSupplySource and cboWLocation.
I populate cboSupplySource with
SELECT [Supply_Sources].[Source_ID], [Supply_Sources].[SupplySourceName] FROM Supply_Sources;
I am trying to get a drop down list in the cboWLocation based on the value in cboSupplySource. I am wanting to see the location names of where the supplies are placed in the warehouse.
I have a requery in cboSupplySource After Update (with cboWLocation as the control name). The SQL that I have come up with so far is:
SELECT Warehouse_Locations.Location_Name,
SupplySource_WarehouseLocation.Supply_Source_ID,
SupplySource_WarehouseLocation.Location_In_ID
FROM Warehouse_Locations RIGHT JOIN (Supply_Sources LEFT JOIN
SupplySource_WarehouseLocation ON Supply_Sources.Source_ID =
SupplySource_WarehouseLocation.Supply_Source_ID) ON
Warehouse_Locations.WLocation_ID =
SupplySource_WarehouseLocation.Location_In_ID
WHERE (((Warehouse_Locations.Location_Name)=[frmInventoryReceivedInput].[cboSupplySource]));
When it runs, on tabbing out of cboSupplySource, Enter Parameter Value dialogue box pops up, looking for frmInventoryReceivedInput.cboSupplySource input. Nothing I input brings up the correct list in cboWLocation.
Obviously, I do not have the correct select statement. Any help would be appreciated.
For cboWLocation try the recordSource query:
SELECT Warehouse_Locations.Location_Name
FROM Warehouse_Locations INNER JOIN (Supply_Sources INNER JOIN
SupplySource_WarehouseLocation ON Supply_Sources.Source_ID =
SupplySource_WarehouseLocation.Supply_Source_ID) ON
Warehouse_Locations.WLocation_ID =
SupplySource_WarehouseLocation.Location_In_ID
WHERE ((Supply_Sources.SupplySourceName)=([Forms]![frmInventoryReceivedInput].[cboSupplySource]))
Be aware, that the combobox columns have to be set to columncount 1 in this case with appropriate column width, because you said you only want to see the location names. Further, you should be sure that cboWLocation is not bound to a Control Source, to not overwrite anything.
You can apply it in VBA at the cboWLocation Enter Event.
In the following code example, the combobox cboWLocation is only updated, if there is a value in combobox cboSupplySource.
Private Sub cboWLocation_Enter()
If not (isNull(Me!cboSupplySource) Or Me!cboSupplySource.ListIndex = -1) then
Me.cboWLocation.RowSource = strSQL 'Put here the previous mentioned SQLString
End if
End Sub
HINT: It would be better for performance, when you change the bound column in cboSupplySource to the PK SourceID instead of the name. (With two columns in combobox cboSupplySource) Then use this PK to compare in your WHERE statement instead of the name. this is what keys in tables are for.
Edit: In the WHERE statement, maybe you have to put the namecomparison between ' ' because it is a string