how to get UNIQUE value in tableau? - tableau-desktop

so I am trying to get the number of data points that have passed or failed based on their ID. However tableau only has COUNTD which does a distinct count and not a UNIQUE count (trust me this will out put two different numbers). Is there a function or formula to get the unique IDs?
One attempt I'm trying to do is count how many times an ID appears and only counting the ones that appeared once, but that is appearing more difficult than I thought. Any other suggestions would be helpful.
I've also tried an LOD function of IF SUM{FIXED([ID]):COUNT([ID])} but that didn't work out either.

Related

Joining of non-unique cells across multiple columns in Google Sheets

I have some personal data with first/last names, e-mails, institutions people work at, etc. There are many, many duplicates because this was collected from a few sources over 2-3 years. Sometimes the same person provided different versions of their name, a different e-mail address, etc. I'd like to have a compact version of this data, where a single person (identified by a PersonID) is listed on a single row, with unique variants of their name, e-mail, etc. listed in each cell. Bonus points if the values in every cell are sorted, but far from required.
Example above also available at https://docs.google.com/spreadsheets/d/1jizgysC1dntZHg8pZ0--dSAPevSfyXyiVyenj02GiwQ/edit#gid=0
I'm looking for a way to display the unique values in each column of a filter result, ideally staying away from =QUERY if at all possible.
This is easy to do when working with just one resulting column:
=FILTER(A4:A9,D4:D9=1) --> =JOIN(", ",UNIQUE(FILTER(A4:A9,D4:D9=1)))
...but the moment the filter spits out results in multiple columns:
=FILTER(A4:C9,D4:D9=1) --> ???
...I have no clue what to do, other than doing the code above for each column separately (which would be a hassle, given the number of columns involved). Is this possible?
Here's one way to do that using MAP:
=MAP(UNIQUE(D4:D),LAMBDA(id,BYCOL(FILTER(A4:D,D4:D=id),LAMBDA(col,JOIN(CHAR(10),UNIQUE(col))))))
By stablishing a column in I with unique values (=UNIQUE(D4:D)), you can use this MAKE ARRAY:
=MAKEARRAY(COUNTA(I4:I),COUNTA(F3:H3),LAMBDA(r,c,
JOIN(CHAR(10),FILTER(INDEX(A4:C,,c),D4:D=INDEX(I4:I,r)))))

Countifs function returns 0 in certain rows

I've recently started using Google Sheets for my new job and I need help with a little problem.
I created a function to compare a whole column of dates from a sheet with dates from another column on another sheet to filter the given count.
The code is as follows:
COUNTIFS('raw data'!$D$2:$D$952;">="&('2nd table'!$C$3:$C$52);'raw data'!$D$2:$D$952;">=01.08.2021";'raw data'!$D$2:$D$952;"<=31.08.2021")
raw data contains dates in column D. I've used 952 because that is the maximum range I can get. I've yet to solve how to implement this via named ranges.
2nd table contains the dates our employees started working at the company. I wanted to filter out the data that exists before their time at our company within raw data column D.
The function does return the correct value sometimes and sometimes it just returns 0.
If I boil down the function to just contain this:
=COUNTIFS('raw data'!$D$2:$D$952;">="&('2nd table'!$C$3:$C$52))
I get different values each time. I suspect that I cannot use the function in this way because the 2nd table got a different amount of rows to compare from.
How can I work around this issue if that's the problem and why does the function even work sometimes?

Excel formula for counting combinations of checked boxes

I need help with a formula that counts unique combination of events from a checkbox form. Users check how many times they completed a task X, Y or Z. The program counts how many events were logged (under '#') and then the counts the unique combination of events and spits out the combo count (under 'Combinations').
For the sake of clarification, I'll refer to each category by its name and each numbered checkbox as X_1, X_2, etc.
Here are the design criteria:
Count unique combinations between two separate events (e.g. [X_1,Y_1])
Once a single instance of an event is counted, you cannot use it again (e.g. X_1 cannot be paired up twice => [X_1,Y_1], [X_1,Y_2])
However, you can pair multiple instances of the same event to other unique events (e.g. [X_1,Y_1], [X_2,Y_2], [X_3,Z_1])
Combinations cannot be made between multiple instances of the same event (i.e. [X_1,X_2] is not valid)
So in the example above, the correct number of combinations should be 3 (i.e. three unique combos of events with each individual event counted only once). I've built two formulas. The first (H2) uses INT and COUNTIF functions to count number of checked boxes column-by-column. It yields an incorrect answer of two.
=INT(COUNTIF(C2:C4,true)/2)+INT(COUNTIF(D2:D4,true)/2)+INT(COUNTIF(E2:E4,true)/2)+INT(COUNTIF(F2:F4,true)/2)+INT(COUNTIF(G2:G4,true)/2)
The second (H3) uses the INT and SUM function to estimate a total from the data container in column A. It yields an incorrect answer of 4.
=INT(SUM($A$2:$A$18)/2)
I believe the MOD function may work well in addition to the COUNTIF function. Go column-by-column, count unique combinations, and any remainder will count towards finding an odd event in the next column.
Any help is appreciated. Thank you for reading.
Does this formula work, in H5? I think it gives the correct number of possible pairings.
=MIN((MAX(1,C10)+MAX(1,D10)+MAX(1,E10)+MAX(1,F10)+MAX(1,G10) - COUNT(C10:G10)),
INT(COUNTIF(C2:G9,TRUE)/2))
It uses a helper row, which totals the number of different users for each possible attempt, in cells C10:G10. This only needs to be entered once.
The formula in H10 is:
=COUNTIF(C2:C9,true)
and it needs to be dragged across under all of the checkboxes, ie in H10 to G10.
Here is my result.
It would be possible to eliminate the helper row, doing the totals below the checkboxes, but it would make the formula very messy I think.

PowerBI counts rows in non related table including filtering and non-matches

I have two tables in PowerBI and a slicer, presented below in an abstracted way.
I want to know the number of orders placed for a customer in a given date range. This data is a sample for illustration - there are actually around 10,000 Customers and 500,000 Orders and both tables have many other fields, Ids etc.
My challenge -
Whilst this is easy enough do by relating the tables and doing a count, the difficulty comes in when I still want to see customers with 0 orders and on top of that I want this to work within a date range. In other words, instead of the customers with no orders disappearing form the list, I want them to appear in the list, but with a 0 value, depending on the date range. It would also be good if this could act as a measure, so I can see the number of total customers that have not ordered on a month by month basis. I have tried outer joins, merge queries, cross joins and lookups and cant seem to crack it.
Example 1: If I set the order date slicer to be: 02/01/2017 to 01/01/2018 I want the following results
Example 2: If I set the order date slicer to be: 03/01/2017 to 06/01/2017 I want the following results
Any help appreciated!
Thanks
This is entirely possible with a Measure. When you're using the Order field to count the rows for each customer, you're essential doing a COUNTROWS() function.
With your relationship still active, we can Prefix this in a measure to check for the blanks, and in those cases, return 0. something like this would work
Measure = IF(ISBLANK(COUNTROWS(Orders)),0,COUNTROWS(Orders))
In this case, 'Orders' is the table containing the Order and Order Date fields

Google Sheets COUNT/FILTER function

I'm having some trouble getting these functions to work. I'm not even sure if they're the ones that I should be using, but here is the following information I can provide. I had previously opened a topic, but I was getting responses about my confusing query. So, hopefully this one is better explained.
I have data in the following fields: A1:N7, as well as A12:L18.
I need a function to check all of the fields and add up the amount of times certain numbers show up. The numbers that need to be checked are: <90, 90-99.99, 100-109.99, and =>100.
First off, I can use this formula to count the <90 and =>100 values in all the fields, which works.
=COUNTIFS(A1:N7,"<90")
However, I'm unsure how to appropriately add the results from A12:L18 into it. My attempts have failed. Likewise, for the ranged functions, I'm completely lost. I've tried something like this:
=COUNT(FILTER(A1:N7,A1:N7>=90,A1:N7<=99.99))
Yet, this always returns 0 as the result. In addition, like the above formula I don't know how I'd nest in a way to check the additional fields in A12:L18.
An old thread, but I came across it trying to solve a similar problem.
Using the original example:
=COUNT(FILTER(A1:N7,A1:N7>=90,A1:N7<=99.99))
I was also getting zero until I realised COUNT returns the number of NUMERIC values in the range. Assuming the result range isn't numeric, I tried:
=COUNTA(FILTER(A1:N7,A1:N7>=90,A1:N7<=99.99))
and got the result I was expecting.
You just need count rows your matrix with ROWS()
=ROWS(FILTER(...))
Does this formula work as you want:
={"<90",COUNTIF({A1:N7;A12:N18},"<90");"90-99.99",COUNTIFS({A1:N7;A12:N18},">=90",{A1:N7;A12:N18},"<100");"100-109.99",COUNTIFS({A1:N7;A12:N18},">=100",{A1:N7;A12:N18},"<110");"=>110",COUNTIF({A1:N7;A12:N18},">=110")}
I made an example sheet where you can see it working: https://docs.google.com/spreadsheets/d/1BPexh5syksapZ9rd_brAa3NkN28LXAvB6dVMLEkM2r0/edit#gid=0

Resources