I need to create a new column containing repeatedly a specific cell value.
In Column1, Row1 the table contains the exam name. Lets say "Exam1". I now need a new column with this text value "Exam1" for all of my students. The new columns name would then be "Exam-Name" and all the rows should have as content the exam name "Exam1".
How can I reference to a specific content in a specific cell and have this text as value for all of my rows in a new column?
Concrete: I need the value "MMA20aL..." to be the value in the row on the right where actually you find the contents "KE21a..."
Thank you for your help. I pretty new to PowerQuery, thank you for a detailed explanation :-)
If you right click the first cell and drill down it will show you a formula. Make note of that formula then remove the drill down step.
Add column ... custom column ... with column name Exam-Name and the formula it showed you, such as :
= Source{0}[Column1]
Where Source in above formula is the name of prior step and Column1 is the name of the first column
So, for example, if prior step is #"Changed Type" and the first column is named Bob then use instead
= #"Changed Type"{0}[Bob]
(As a note, your data is in a terrible format and needs much massaging before it would be really useful)
Related
The problem is probably trivial but unfortunately I can't figure it out. Here are two basics tables:
I tried to create the matrix based on the selected ID (from the Table2) with values from Table1. I created a measure "% Margin" (margin divided by revenue) and tried to add this to the matrix with ID from Table2. Every time besides ID from Table2 I got one additional row with empty ID. Anyone has an idea how to get rid it off? The rest of the matrix is correct.
Instead of using a separate static table, simply add a new column to you table and use that to filter your data for the report.
Here's how this would look like:
I have a workbook where I have displayed a table where the user can view the top 3 IDs based on a column they can select from a dropdown (Measure A, Measure B, ... , Measure H):
Now, instead of this, I want to add a separate column called Sorting Criterion to the table that would store the column names with which the respective rows of the table was sorted. So, the expected output is something like this:
How do I do this? I'm open to using Tableau Prep Builder, if needed, for intermediate steps that may be too convoluted for Tableau Desktop.
Create a calculated field that just contains the Sort By parameter. Add this calculated field to your view.
If I want to expand this embedded table...
...and I click on the expand button, I'm presented with the dropdown to select which columns I want to expand:
However, if I choose '(Select All Columns)' to expand them all, Power Query turns that into hard-coded column names of all the columns at the time I do that. Like this:
= Table.ExpandTableColumn(Source, "AllData", {"Column1", "Column2", "Column3", "Column4", "Custom"}, {"Column1", "Column2", "Column3", "Column4", "Custom"})
After that, if the underlying embedded table's columns change, the hard-coded column names will no longer be relevant and the query will "break."
So how can I tell it to dynamically identify and extract all of the current columns of the embedded table?
You can do something like this to get the list of column names:
List.Accumulate(Source[AllData], {}, (state, current) => List.Union({state, Table.ColumnNames(current)}))
This goes through each cell in the column, gets the column names from the table in that cell, and adds the new names to the result. It's easier to store this in a new step and then reference that in your next step.
Keep in mind that this method can be much slower than passing in the list of names you know about because it has to scan through the entire table to get the column names. You may also have problems if you use this for the third parameter in Table.ExpandTableColumn because it could use a column name that already exists.
Try using Table.Join which joins and expands the second table in one step.
"Merged Queries" = Table.Join(Source,{"Index.1"},Table2,{"Index.2"},JoinKind.LeftOuter)
You just need to make sure that the columns between the tables are unique.
Use Table.PrefixColumns to ensure column names are unique
How to check whether a column was deleted completely in a webtable using VB script?
I've created a row in a webtable and deleted it. I'd like to check whether the column is deleted from that webtable or not. I've written a script and having a tough time to write the logic. I can get complete row count from a webtable and can loop through one by one. But how to check whether that column was deleted from the webtab?
rowCount = SwfWindow(obj).SwfTable(tbl).RowCount
For i = 0 To rowCount - 1
names = SwfWindow(obj).SwfTable(tbl).GetCellData(i, 1)
If names = mycolname 'mycolname is the name of the column deleted Then
SwfWindow(obj).SwfTable(tbl).ClickCell i,1
Print "col name is present in the table"
Exit for
else
Print "col name is deleted completely from the table"
End If
Next
How do you want to identify the column? Probably by name. (The code shown in the question indexes by numeric index.)
It then depends on the webtable´s structure:
There is a WebTable runtime property returning the name of all columns in a string separated by a semicolon; iterate over the components of this string and query their names in the loop. If you find the to-be-deleted column in the process, it is still present, if not, it´s deleted.
See http://www.sqaforums.com/forums/hp-unified-functional-testing-uft-mercury-quicktest-pro-qtp/148239-qtp-function-web-table-get-column-number-giving-column-name.html for an example.
Sometimes, the table is organized a bit different, and the getROProperty call returns garbage. Then, you usually find the column names as cell data in row 1. There, you would need to iterate over the columns and use getCellData to look at the column name.
As pointed out by #TheBlastOne, the table you see in the AUT (application under test) does not necessarily tell the whole truth about how it is actually structured. The following is a neat trick, which should work for both WebTable and swfTable, to be able to see the actual structure of a table:
When you have both the AUT and QTP open, click the "Record" button in QTP
Choose to start recording on the open application
On the toolbar menu in QTP, select "Insert" --> "Checkpoint" --> "Standard Checkpoint" and click on the table in the AUT
A new window should now have opened, which, among other things, shows you exactly how the table is structured, i.e. row indexes and/or names, column indexes and/or names, etc.
I have an issue with an excel spreadsheet I want to see if I can do without VBA just because it seems easier to implement that way. Basically, there are many columns in the sheet I want to sort. However, I merely want to look at three columns: the title column, the data column and the status column.
In a new spreadsheet, there will be four sections. Each section corresponds to 3 months of the year (ie Jan, Feb, Mar. will map to the first column on the new spreadsheet, April, May, June will map to the second column on the new spreadsheet).
Based on the date, and if the status column has the word "Finished" (in the original spreadsheet), I want to map the title to a certain column under the new spreadsheet based on the date criteria as described in the previous paragraph. So for example, if the original spreadsheet has following:
Title Date Status
Doc1 1/12/13 Finished
Doc2 2/10/13 UnFinished
Doc3 4/1/13 Finished
Doc4 3/31/13 Finished
Would map to, on the new spreadsheet:
1st Column | 2nd Column
Doc1 Doc3
Doc4
I have looked a lot into pivot tables but I can't "automate it" as much as I want to. I have gotten it down to the point where I can change the pivot tables into filtering based on date, but I want it even more automated than that. I've also tried excel formulas but that has been to no avail. Thanks for the help, I really appreciate it!
With a PivotTable it seems fairly easy to 'automate' as far as Sheet 2 as below:
but from there to the result requested is relatively 'manual' without VBA, so may not suit.
For my convenience I have changed the date formats. The PivotTable is constructed as usual/indicated without showing grand totals for rows or for columns (PivotTable Options, Totals & Filters). The Column Labels are Date with Grouping By Quarters with appropriate Starting at: and Ending at: (Group) and Collapse Entire Field (Expand/Collapse).
The formula in I6 is to convert the document count (always 1) to document name:
=IF(F6=1,$E6,"")
However, to allow room for additional quarters in the PivotTable the formula should be moved to the right. The formula would need to be copied across and down as necessary.
The process becomes more ‘manual’ with copying the results of these formulae, pasting them (with Special / Values) into a new location (in the example 2!A1) and, if required, deleting blanks.
This may be against the rules with regards to maintaining the integrity of the OP's request, but hopefully it doesn't offend :)
Here's another option.
Add another column (shame on me, I know) to the original data, and
called this Quarter. The formula that goes next to the existing data
is the following.
=IF(C2="Finished",IF(MONTH(B2)<=3,"Q1",IF(MONTH(B2)<=6,
"Q2",IF(MONTH(B2)<=9,"Q3","Q4"))),C2)
Basically, if the status is "Finished", then determine in what quarter the date is.
Create the pivot table with that data, and then add "Quarter" and
"Title" to the Row Labels (in that order)
Last thing would be to click the arrow next to "Row Labels" and select "Does not Equal" under "Label Filters". There you'll type "Unfinished" (no quotation marks). This will give you something like the image below.
From here the only manual thing you'll need to do is update the data range for the pivot table if more rows are added to the pivot table data and refresh the pivot table if the original data changes
NOTE: To address your question about sorting; after you do the steps above, you can select the Row Labels again and do an A>Z sort to get each quarter to be sorted in alphabetical order