How to filter selective data from a postgres using PDI components? - regex

For example : I have a column named description, in this column there are millions of records. I just want to filter records only with "a=x" (where x can be any value) using pentaho?.This pattern can be at any position in the column

Assuming that in your description column you always have a value after the pattern 'a=' you could just do the filtering in PostgreSQL using LIKE
SELECT
description
FROM
your_table
WHERE
description LIKE '%a=%'
Then you just put this query inside a Table Input step in your transformation.

Related

Apache Superset How can I pass a filter value from a filter box to a SQL query Group By clause

I have a superset dashboard wherein i have a filter box containing the name of various dimensions such as area, district, country and so on. I want to generate a run time query to compute the value of a specific metric group by each of these dimensions. The user will select a value of the name of each dimension from the filter box and the dash should run the query for example:
SELECT
SUM(REVENUE),
{{dim}}
FROM mytable
GROUP BY {{dim}}
WHERE dim can be 'area' or 'district' or 'country'
How can I achieve this using Jinja templating ? Looking for any examples that would be helpfull ?
You need to use different column names in Filter and your chart.
An example of the same is here:
https://github.com/apache/superset/discussions/15272

Power BI : How to count occurrence of value from source table?

I have my data source something like below.
I need to show output in the report as below.
I tried using the unpivot column and getting something like this, how to count the occurrence value of each Business value.
Plot following mesure against Value column (from your unpivot table):
Business Occurance = COUNTROWS('your unpivot table')
We have to remove the Attribute column as the next step to Unpivot. Then my table should be looks like this.
Now create a new table with following Dax function, let's say the current table as Business Data (Your Unpivot table)
Occurrence Table = DISTINCT('Business Data')
Now end result table should look like this,
You can make use of this table for your table visual in the report.
Note: You can add n-number of rows and column into your source table and this logic will do magic to get the correct result.
I have marked two places first marked place you have to add Value column then click second marked place one dropdown value is open click count menu

Need to apply filter on using OR condition

I have Dataset in PowerBI as below.
In PowerBI Desktop I want to filter records of below table based on condition described below.
ProjectName ReleaseDate UserReleaseDate
PROJ-1 12/09/2019 null
PROJ-2 null 02/02/2019
PROJ-3 07/07/2018 null
Date are in DD/MM/YYYY format.
I want to filter those records where
(ReleaseDate OR UserReleaseDate is IsInNextNYears(1))
You pretty much just do exactly what you described.
Table.SelectRows(YourTable, each (Date.IsInNextNYears([ReleaseDate], 1) or Date.IsInNextNYears([UserReleaseDate], 1)))
If you use any filter operation on a column in Power Query it will automatically create a Table.SelectRows step that you can edit to do what you want instead.

Do flowfields Value Change if Filters are applied to the Table?

I have a flowfield that sums up a decimal value, but I need to limit the value in a report based on a date field that will be supplied as a parameter in a
report. How best do I achieve this?
a shortened version the CALC formula in the field definition looks like this:
Sum("MyTable".Unit WHERE (Institution=FIELD(No)))
When the report is run, there is a filter on MyTable based on a date field.
Does this field evaluate to the total sum of all the records, or just the filtered values?
No. Just filter on any field doesn't applies to flow fields.
You must use flowfilter to achieve this.
Your code should look like this:
MytableVar.reset;
MytableVar.setrange("Date Filter", 0D, TODAY);
MytableVar.calcfields(Unit);
where Date Filter is a field in the My Table with type flowfilter.
If My Table is used as Source Table it will work in tha same way. Just apply filter to Date Filter field.
For further reference see Inventory filed in the Item table.

Wildcard search on Date fields

I use HSQLDB2.0 and JPA2.0 for my current project and have few date columns in DB.
I would like to run wildcard queries on the date columns. How could I do that?
Ex : If my DB contains two rows with date values as : 10-01-2011 and 15-02-2011
and my search criteria will be "%10-01%", then result should be 10-01-2011.
Else if search criteria is "%2011%" then both rows need to be fetched with the select query.
Thanks in advance,
Satya
You can define an autogenerated column of type VARCHAR containing a copy of the date. You can then perform queries with both LIKE predicates and REGEXP_MATCHES() function. An example of the column definition is below:
DATEGEN VARCHAR(10) GENERATED ALWAYS AS (CAST(DATECOL AS VARCHAR(10))
Note the string representation of DATE is in the form '2011-02-26' and your query strings should follow this pattern.
This can be achieved in this format :
select date_birth from member where to_char(date_birth,'MM-yyyy') like '%02-2011%'
select date_birth from member where to_char(date_birth,'MM-dd') like '%02-15%'
select date_birth from member where to_char(date_birth,'dd-yyyy') like '%30-2011%'
Regards,
Satya