Pick unique values from two non-adjacent columns - if-statement

Please see the attached sample: https://docs.google.com/spreadsheets/d/1m625-WxG9VBv5AG-VR9-pf4bUCcG8AMCrb_z3jMYCqo/edit#gid=0
Columns A,B,D and E are my source columns. I want to pick unique values from columns B and E for each date into a dynamic table (Columns G, H and I). As shown in columns H and I, unique values from each column are to be adjacent to each other.
I have tried using the following formula: =unique(filter(A2:E,{1,1,0,1,1})) However, this returns two separate columns for dates.

try:
=ARRAYFORMULA(UNIQUE(QUERY({
A2:B, IFERROR(B2:B/0, B1), ROW(B2:B);
D2:E, IFERROR(E2:E/0, E1), ROW(B2:B)},
"select Col1,max(Col2)
where Col2 is not null
group by Col1,Col4
pivot Col3
order by Col1 desc")))

Related

How to create dynamic ranking excluding one column the table in Power BI?

I have a summary table as input to Power BI, sample shown below:
Col1
Col2
Col3
Profit
A
P
E
546
A
Q
F
456
A
P
F
343
A
Q
E
897
I have created a report in Power BI using dynamic ranking. I have used following expression for rank measure:
Rank = RANKX(ALLSELECTED(Table), Calculate(sum(Table[Profit])), ,DESC, Dense)
But when filters are applied, above rank is re-generated using all the 3 categorical columns into consideration. But I would like to re-generate ranking based on only 2 columns (suppose col1 and col2 only) when filters are applied and col3 column is only used for filtering purpose. How can I achieve it?

Create a list of unique values and the times repeated across

I'm obtaining a list of unique values with this formula:
=ArrayFormula(VLOOKUP(UNIQUE(REGEXEXTRACT(FILTER(A2:A1000,A2:A1000<>""),"\d+"))&"*",REGEXEXTRACT(A2:A1000,"\d+.+$"),1,FALSE))
I did this for 3 different sheets, in each sheet has different values but in some cases these are repeated across the sheets like this:
These are the final list after the formula:
After this I used this formula
=COUNTIF(Sheet3!$A$2:$A$500,A2)+COUNTIF(Sheet4!$A$2:$A$500,A2)+COUNTIF(Sheet5!$A$2:$A$500,A2)
I get this:
Actually it works as I want but is not a dynamic function I would like to have the list of the unique values and the times appearing across the sheets if is possible
Here is the problem with some text in the row that I have with []
Use below QUERY() formula-
=QUERY({Sheet3!A:A;Sheet4!A:A;Sheet5!A:A},"select Col1, Count(Col1)
where Col1 is not null
group by Col1
label Col1 'List of Values', Count(Col1) 'Count'")

Need a way to dynamically sum multiple columns into a Merged cell of varying heights

In this scenario, I am looking to total Columns G through M by 'user' in Column E. Column N does have the correct data, but it is using the formula =sum(f4:m5). I am looking for a way to add an array formula because the heights of the merged cells in column N varies often. A formula would be preferred to a script in this case.
try:
=INDEX(IFNA(VLOOKUP(F2:F,
QUERY(SPLIT(FLATTEN(IF(G2:M="",,F2:F&"♀"&G2:M)), "♀"),
"select Col1,sum(Col2) group by Col1"), 2, 0)))

How to collapse sheet by pivoting rows into csv data

I have a set of data where an account id can have multiple rows of country. I'm looking for an array function that will give me a unique list of accounts with the countries in the second column as csv values e.g. country1,country1,country3.
If I unique the accounts, this query will do it per row but I'm really looking for an array so I don't have to maintain it as the number of rows grows.
=TEXTJOIN(",",1,UNIQUE(QUERY(A:B,"select B where A = '"&D2&"'",0)))
I have a sample sheet here.
try:
=INDEX(REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(QUERY(
IF(A2:A="",,{A2:A&"×", B2:B&","}),
"select max(Col2)
where not Col2 matches '^×|^$'
group by Col2
pivot Col1"),,9^9)), "×")), ",$", ))

sap hana calculated column check for multiple IDs

i want to create a calculated column, which will show two values: Y or N
2 columns are here important, "VAT-ID" and "CUSTOMER-ID". the calculated column will check if a customer-ID has multiple VAT-IDs. If yes the value "Y" should be displayed, else "N".
for example, the first 5 rows of the customer-id column are:
123456
654321
666666
123456
654321
the first 5 rows of the VAT-id column are:
EE999999999
AA999999999
GG999999999
KK999999999
AA999999999
the first 5 rows of the calculated column should be then:
Y
N
N
Y
N
any Help would be appreciated
Calculated columns don’t allow for aggregations across groups or other than the current row.
What you can do to achieve your goal is to create a separate aggregation node and count distinct VAT-IDs grouped by CUSTOMER-ID.
With this, you can now have a calculated column that checks for VAT-ID-COUNT > 1 and map it to your Y/N values.
As Lars mentioned it is not possible to use a window function within a calculated field on HANA table
But you can use following query to check if VAT number is multiple for a customer or not
select
CustomerId, VATID,
case
when (count(*) over (partition by CustomerId, VATID)) > 1
then 'Y'
else 'N'
end
from CustomerVAT;