PowerBI: Filter out columns with null values - filter

I need to union multiple datasets with different schema into one dataset with all columns. For example: Table 1 has columns: table_name, 1A and 1B and Table 2 has columns: table_name, 2A and 2B. So the final table would have columns: table_name, 1A, 1B, 2A and 2B.like below. I need to represent the final dataset using Table visual in PowerBI and my aim is to use a table slicer to filter out unrelated columns. For example, if I select Table 1 in slicer, the table view should only display columns 1A and 1B and filter out columns 2A and 2B since they have no relevance to Table 1. Likewise, when selecting Table 2 from slicer, it should only show columns 2A and 2B. I thought this can be easily achieved in PowerBI but i was wrong.
Anyway who has worked out a solution please could you let me know? Many Thanks!
Table1Table1
Table2Table2
FinalTableFinalTable

The suggestion is to use the column name same for both tables. Then you will have 3 columns in your final table like- table_name, column_a and column_b. rest is as simple as you planned.
I did some play with your requirement as I know the end user can ask for anything whether it makes sense or not. I have created a table considering your condition as below-
The next step is I have applied some transformation to the data, so that I can achieve the requirement in the visual layer.Here below is the output I will use in the visual. I have added an extra column Index which will be used in the visual for some purpose-
Now, in the visual layer, I have used a Matrix (only option) to implement the option of adding and removing columns dynamically. You have to bear an extra column "Index" in the visual for no reason, but you can take it as row_number :)
Now, if you select a table name from the slicer, you will only see values/rows from that specific table as below-
You can check the Power BI file from here.

Related

How to populate columns of a new hive table from multiple existing tables?

I have created a new table in hive (T1) with columns c1,c2,c3,c4. I want to populate data into this table by querying from other existing tables(T2,T3).
E.g c1 and c2 come from a query run on T2 & the other columns c3 and c4 come from a query run on T3.
Is this possible in hive ? I have done immense research but still am unable to find a solution to this
Didn't something like this work?
create table T1 as
select t2.c1, t2.c2, t3.c3, t3.c4 from (some query against T2) t2 JOIN (some query against T3) t3
Obviously replace JOIN with whatever is needed. I assume some join between T2 and T3 is possible or else you wouldn't be putting their columns alongside each other in T1.
According to the hive documentation, you can use the following syntax to insert data:
INSERT INTO TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1 FROM from_statement;
Be careful that:
Values must be provided for every column in the table. The standard SQL syntax that allows the user to insert values into only some columns is not yet supported. To mimic the standard SQL, nulls can be provided for columns the user does not wish to assign a value to.
So, I would make a JOIN between the two existing table, and then insert only the needed values in the target table playing around with SELECT. Or maybe creating a temporary table would allow you to have more control over the data. Just remember to handle the problem with NULL, as stated in the official documentation. This is just an idea, I guess there are other ways to achieve what you need, but could be a good place to start from.

How to select row data as column in Oracle

I have two tables like bellow shows figures
I need to select records as bellow shown figure. with AH_ID need to join in second table and ATT_ID will be the column header and ATT_DTL_STR_VALUE need to get as that column relevant value
Required output
Sounds like you have an Entity-Attribute-Value data model which relational DBs aren't the best at modeling. You may want to look into a key-value store.
However, as Justin suggested, if you're using 11g you can use th pivot clause as follows:
SELECT *
FROM (
SELECT T1.AH_ID, T1.AH_DESCRIPTION, T2.ATT_ID, T2.ATT_DTL_STR_VALUE
FROM T1
LEFT OUTER JOIN T2 ON T1.AH_ID = T2.AH_ID
)
PIVOT (MAX(ATT_DTL_STR_VALUE) FOR (ATT_ID) IN (1));
This statement requires you to hard-code in ATT_ID however there are ways to do it dynamically. More info can be found here.

Informatica target table populating

I am new in Informatica,here i am trying to populate my target table by joining two tables where the no. of rows in both the table is 5649 and 2611 respectively.So, my output rows should be 8260.But the no. of rows rows in target table is around 108860 (approx.).
Why this is happening and how should I remove it?
It seems to me that you are confusing the join operation with union.
You need to merge two sets of rows into one, so use a Union transformation, not a Joiner.
if table structure isn't same pick/select only common columns and then perform a union in SQ Override..

Cognos Report Studio Total of Column based on Distinct values of Column2

Cognos by default suppress duplicate/identical records. Duplicate rows do not appear in the report, but summaries are performed on all rows - including the duplicates that were eliminated.
To perform summaries on only the distinct rows, you must add the distinct key word when creating the summary definition. For example, the following summary:
Total(MyColumn)
Would become...
Total (distinct MyColumn)
But I would like Total of Column1 based on Distinct values of Column2. How to do this?
I assume your report is built on top of relational model.
The short answer to your questions is using FOR clause:
Using the AT and FOR Options with Relational Summary Functions
So you can do something like this:
Total(distinct MyColumn for Column2)
My question is why would you think distinct on one column is different from other column?
Cognos "eliminate" duplicate rows only if two or more rows are completely identical.
If one of the columns is different, then it's not a distinct row.
You can use grouping instead, which group together identical values on single column.

Sorting a table using a subrepot column in SSRS. Is this possible?

I'm using SSRS 2005. I've got a table with various inventory data. In one columns I've got a subreport that is designed to pull the date of the most recent Purchase Order based upon the product code of whichever row the subreport is in. This would be fine, however I'm now being asked to be able to sort by this date column. My assumption is that you cannot sort a column with a subreport in it, but I thought I'd ask. Is there any way to do this?
You can include the most recent purchase order value in your main report's dataset as a subquery like this:
SELECT *
,(SELECT TOP 1 PurchaseOrder
FROM Purchasing p
WHERE p.ProductCode = i.ProductCode
ORDER BY PurchaseDate DESC
) as LastPurchaseOrder
FROM Inventory
Then you can use that value to sort your table.

Resources