Birt Report Grouping - grouping

I have 2 columns: fltrte_P1_Plt_Per_Id_Fk (Pilot) and fltrte_P2_Plt_Per_Id_Fk (Co-Pilot).
When displaying data in the report I need to group based pilot name. He may be pilot or co-pilot.
It should come in same group. How can this grouping be achieved in a Birt report?

I suggest amending your query from:
select fltrte_P1_Plt_Per_Id_Fk, fltrte_P2_Plt_Per_Id_Fk, ... from flight_Log_Table
to:
select fltrte_P1_Plt_Per_Id_Fk as group_By, ... from flight_Log_Table
union all
select fltrte_P2_Plt_Per_Id_Fk as group_By, ... from flight_Log_Table
then amend your report to group on the new group_By field in the query.

Create a new column that combines the two in your SQL Query.
ISNULL ( fltrte_P1_Plt_Per_Id_Fk, fltrte_P2_Plt_Per_Id_Fk ) as 'Pilot'
If there is a value for P1 (Pilot) it will be in the new field 'Pilot', otherwise P2 (Co-Pilot) will the new field 'Pilot'
This solution works in BIRT 4.2 using a 2008 R2 database.

Add the GROUP BY clause Group by Pilot, Co-Pilot to the end of your SQL query.

Related

How to convert this SQL query to Django Queryset?

I have this query which selects values from two different tables and used array agg over matched IDs how can I get same results using the queryset. Thank you!
select
sf.id_s2_users ,
array_agg(sp.id)
from
s2_followers sf
left join s2_post sp on
sp.id_s2_users = sf.id_s2_users1
where
sp.id_s2_post_status = 1
and sf.id_s2_user_status = 1
group by
sf.id_s2_users
You can run raw SQL queries with Django's ORM if that's what you wanted. You don't have to change your query in that case, you can check documentation here.

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

Can I add a filter to a SELECTCOLUMNS so that I can use two different table depending on the filter in DAX

I am using DAX Studio and I would like to add a filter to the table field in SELECTCOLUMNS so that it using two different table depending on the filter's expression result.
In other words what I would like to do is similar to the following :
DEFINE
VAR cond_talble =
SELECTCOLUMNS(
IF(#param1="1",TABLE1,TABLE2),
"column1",[column1],
"column2",[column2]
)
Thank you kindly
there is a work around for this problem but might not be a good one for everyone, and it's to add a column in both tables containing a boolean that is set to true for table1 and 0 for table2 and then (if your trables contains the same columns like me) get a table that is the fruit of the union of both tables and add an if condition on a filter so that you filter with the added column

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.

Using another table in BigQuery Regex

I would like to map a string column to a category based on a regular expression match.
Is it possible to use another bigquery table containing the regular expressions and corresponding category for this? This would make it easier for me to update only a table when adding new categories/updating the regex, instead of having to update all queries that would use this lookup.
Query:
CASE
-- Use the entries from another table here
WHEN REGEXP_MATCH(string_to_check, cat1regex) THEN cat1
WHEN REGEXP_MATCH(string_to_check, cat2regex) THEN cat2
etc.
END
Mapping table:
Regex category
pagex|pagey xy
pagez|page1 z1
It's also possible there is another simple way to do something similar that I'm not thinking of, answers pointing those out are welcome too.
Any help would be appreciated.
Below is for BigQuery Standard SQL
#standardSQL
SELECT
string_to_check,
MAX(IF(REGEXP_CONTAINS(string_to_check, reg), category, NULL)) AS category
FROM yourTable
CROSS JOIN mappingTable
GROUP BY string_to_check
You can test / play with it using below dummy date from your question
#standardSQL
WITH `mappingTable` AS (
SELECT r'pagex|pagey' AS reg, 'xy' AS category UNION ALL
SELECT r'pagez|page1', 'z1'
),
`yourTable` AS (
SELECT string_to_check
FROM UNNEST(["pagex.com", "pagez#example.org", "page.example.net"]) AS string_to_check
)
SELECT
string_to_check,
MAX(IF(REGEXP_CONTAINS(string_to_check, reg), category, NULL)) AS category
FROM yourTable
CROSS JOIN mappingTable
GROUP BY string_to_check