Extract the values from a table based on a rule and create a new table

Satya123

New Member
Joined
Jan 24, 2020
Messages
3
Office Version
2016
Platform
Windows, MacOS
Hi I am quite new to power bi and trying to learn how to use DAX and other power bi queries. I have been trying but not able to get what I want from my below query.
I hope someone can help.

I have same data in below 2 formats and I want the output table as below. Any data table can be used to get the output

Data table 1 with format 1

Rolename status hostname
Role-A HELD Server-A
Role-A NOT HELD Server-B
Role-A NOT HELD Server-C
Role-B HELD Server-A
Role-B HELD Server-B
Role-B NOT HELD Server-C
Role-C NOT HELD Server-A
Role-C NOT HELD Server-B
Role-C NOT HELD Server-C


Data table 2 format 2

Rolename status hostname status hostname status hostname
Role-A HELD Server-A NOT HELD Server-B NOT HELD Server-C
Role-B HELD Server-A HELD Server-B NOT HELD Server-C
Role-C NOT HELD Server-A HELD Server-B NOT HELD Server-C



I want the output in a table like this as below or How can I display the above table data in Visualization using any graph/filter which can show below output ???


Output Table Format (should contain all unique role names even if no role is HELD against it)

Rolename Server-A Server-B Server-C
Role-A HELD
Role-B HELD HELD
Role-C
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

peter789

Board Regular
Joined
Nov 20, 2016
Messages
114
Power Query is the way to go.
In first case Pivot the data on host name with status as the value column with no aggregation. Then replace "NOT HELD" with blanks.
In the second case you need to transform the data into the same format as the first table. One way is to merge the pairs of columns with a distinctive delimiter (status, hostname). Then select the rolename column and unpivot the other columns. Split the merged column on the delimiter you used then apply the same transformation steps used in the first case.

Peter
 

Satya123

New Member
Joined
Jan 24, 2020
Messages
3
Office Version
2016
Platform
Windows, MacOS
Many thanks Peter, this is exactly what I was looking for and power query worked perfectly fine. I used the data from the first case and did the pivot as you have suggested.

Thanks Again.
 

Satya123

New Member
Joined
Jan 24, 2020
Messages
3
Office Version
2016
Platform
Windows, MacOS
Hi @peter789 is there a way I can sort this output also?? Like I want to sort the rows based on number of count of the keyword HELD
Total number of count of HELD for all hosts is 1 for a role then it should be no. 1
If total number of count of HELD for all hosts is 2 for a role then it should be no. 2 n so on...

Table like below

Rolename Server-A Server-B Server-C

Role-A HELD
Role-B HELD
Role-C HELD HELD
Role-D HELD HELD HELD
 

peter789

Board Regular
Joined
Nov 20, 2016
Messages
114
One way would be to create a second query connected to the original source data which is in an un-pivotted format. Filter status by HELD then just keep the Rolename and status columns. Group by rolename aggregate on count rows. Merge original query with this one joined on rolename. Expand table to add count.
Peter
 

Watch MrExcel Video

Forum statistics

Threads
1,095,204
Messages
5,443,013
Members
405,212
Latest member
Arnie58

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top