Tableau - multiple columns with True and False values - if-statement

I have 10 columns with True and False values. I would like to create a dashboard where if one column is True and another column is also True, a graph displays a count in that column. For example: if column A is True, column B if False, column C is True - then it would return a count for column C.
I would like a parameter setup where a user can select one of the ten columns and it would show in a bar chart the count of other columns that are True when that column is True.
The first part is where I am having trouble - I haven't gotten to the second part yet. Any help is appreciated.

Related

Measure max datetime per Id in Dax

Suppose that you have a table with two columns ("ID","DATETIME").
For each "ID" there are multiple rows with different datetimes.
I want to create a third column named "IS_LAST" which has a Boolean data type.
For each row I want to filter the table with the "ID" present in the row and want to check if the "DATETIME" in row is the latest. If yes, "IS_LAST" goes to TRUE else FALSE.
My tentative is: IF(COUNTROWS(FILTER(TABLE, TABLE[ID] = [ID] && TABLE[DATETIME] > [DATETIME]) = 0)), TRUE, FALSE). But this gives TRUE for all rows.
Is Last =
VAR latest = CALCULATE(MAX('Table'[time]), ALLEXCEPT('Table','Table'[id]))
RETURN
IF(SELECTEDVALUE('Table'[time]) = latest, TRUE())

Add a conditional column in Power BI Power Query

I am trying to add a conditional column in Power BI Power Query. I have three columns with values. If all three columns return a value, then the conditional column should return true. If any column returns a null value, then I want the conditional column to return false. Newbie here and I just cannot figure it out. Any help is appreciated.
In M, add a custom column
= if [columnname1]=null or [columnname2]=null or [columnname3]=null then false else true
that assumes they are real nulls, instead of blank strings, which might require =""
Just another way to do it (Power Query M)
'Source' is the name of the previous step and you have to adapt it when inserting it.
'Column1', 'Column2' and 'Column3' are the column names you also have to adapt.
= Table.AddColumn(Source, "AllColumnsWithData", each if List.AllTrue({[Column1]<>null,[Column2]<>null,[Column3]<>null}) then true else false)

get values from first column when other columns are true using a lookup list

I have a source table with a variable number of columns. The first column is a name, and the remaining columns are type with values of true or false based on my data.
I also have an input lookup column that will have the names of the types.
Based on the types selected in the lookup column, I want to return the names from the source column that has true for any of the selected types.
It is hard to explain so I made a sample sheet with expected output and explanation at https://docs.google.com/spreadsheets/d/1U7-Vz8tq-4E1Z6jkVFzsoIvW8VHRJNGw0oqDE1LUKOI/edit?usp=sharing has sample input and my expected output.
New rows could be added to the source table, and new columns (types) could be added too. One thought I was to have a formula for each row in the source table checking the column based on what is in the lookup table but I want to avoid that because new rows/columns could be added to the source table.
I'm hoping for a single arrayformula or something efficient. I have been looking at this for hours with no luck. I don't even know where to start...
for H9:
=ARRAYFORMULA(UNIQUE(TRIM(QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(B3:F=TRUE, "♠"&B2:F2&"♦"&A3:A, )),,999^99)),,999^99), "♠")), "♦"),
"select Col2 where Col1 matches '"&TEXTJOIN("|", 1, G9:G)&"'"))))
for H3:
=ARRAYFORMULA(UNIQUE(TRIM(QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(B3:F=TRUE, "♠"&B2:F2&"♦"&A3:A, )),,999^99)),,999^99), "♠")), "♦"),
"select Col2 where Col1 matches '"&TEXTJOIN("|", 1, G3:G6)&"'"))))

M query - Edit the value of cell H2 in a table

Having imported an excel sheet into power query, I need to tidy it up by changing the value of a particular cell.
At the moment that cell has a null value, but there are other null values in the same column that I do not want to change. – So I cannot replace all of the null values in that column with another value.
I also cannot correct that particular cell in the source excel file (there are hundreds of them, which were created before I arrived).
I basically need some syntax for example that sets the value of cell H2 to “Jeep”, but not to change any other cells.
Very grateful for any insight.
One way would be:
In the Power Query Editor:
Add an index column starting from 1 (tab Add Column)
Add a Conditional column: If [Index] = 2 then Jeep else [H] (tab Add Column)
Delete Index column and [H] Column
Rename Custom column to [H].

Compare a value from two column and get matching value from another table Power BI

I am fairly new to powerbi and I need your help in one task on which I am stuck on.
Basically I have two tables and I need to compare the value from table one with a row of table 2 and return the output.
Table 1
I need to compare values in column a & b and get a match from table 2.
For example if row 1 has BY Green & BS HIGH then I need to check this value from matrix table below and return the output in column value as either 0 or 1.
Table 2
As you can see the Table 2 first row has value BY Green and BS low has a value '0'
Try this...
Index() returns a value from the matrix (in purple) based upon the intersections of the two match()'s. The first is the Vertical match in from the Table1:Col A; the second is the Horizontal match from table1:Col B. The value found at that intersection is returned.
... My apologies ... just saw this was a BI request... no worries...
First, Need fixup table2 as a lookup file:
First, click a cell in table 2 (don't edit), then Data menu >frm table/range, will bring up the Power Query window. Select columns B (not A) through Col F), then in the PQ Transform menu > Unpivot to create the new lookup table. this can either be saved as a new table or be used by reference.
Next, open and merge Table 1 PQ_Table 2 (Be sure to select BOTH Columns in BOTH Tables, in the same order). Then, expand the table tab following the merge expand the table tab. I only selected the value to return but you can return all the values to verify, then delete the unneeded columns.
Hope this helps...
Good Luck.