VBScript - Reading data from excel list - vbscript

I have a couple of questions on reading data from excel sheet using vbscript code and storing
them in a dictionary object.
1) This is more excel specific. Can I do Data filtering on an excel based on what I select in a master column. For Ex: I have a column name TicketType which has a list of values namely Type1, Type2, Type3. If I select Type1, the data in the remaining columns should show data specific to Type 1, when I select Type2, the remaining columns should change to data specific to Type2.
2) If point one is possible in excel, I would want to use VBScript to select the value first in the master column and then read the filtered data in to a dictionary. I would request for some help here. My whole idea is not to create more rows and instead use one single row and keep filtering and reading.
Thanks
Srinivas

Related

How to Combine Excel files that contain valid tables and Remap column Names - Power Query Function

I’m making a Power Query (M Code) that combines all Sheets in Workbooks stored in a folder. The logic is the following
Read folder content
Form a list of Workbooks(Sheets) within
Invoke a Function to “Format” content of each Sheet to append the records in a consolidated table
The invoked Function on every Sheet should:
Identify where the “Titles" Row is located
Remove “n” records until “Titles" Row
Remap “Titles" to a standard Name from HeaderMap table
Reorder the columns according to HeaderMap table
Promote the “Titles” Row to Columns Headers
Change column types according to HeaderMap table
Remove “Blank” records
The caveat is that I may encounter Sheets that have no useful information. I need to peek inside the Sheet to verify if valid content and then execute the function to format. How can I Skip the Sheet when consolidating all tables? Something like
Identify indexed row where the “Titles” are located
If (no valid “Titles” found) then Skip Sheet
else (continue with remaining steps)
Thank you in advance

Create a summary table based on data from another table in Power Query

I am new and pretty inexperienced with Power Query, so have struggled with this issue and finding a basic tutorial on Power Query.
I am using Power Pivot to analyse some data. My source data is added to the Excel Data Model using Power Query from an external CSV file.
What I want to be able to do is create a summary table from the source data in a new table. This new table would be added to the data model. My source table (SrcTable) would look like this;
Order ID
Item Code
O-001
I-001
O-001
I-002
O-002
I-001
O-003
I-001
O-003
I-002
O-003
I-003
My new table would have two columns
A list of each Item Code
A Distinct Count of Order ID for each Item Code
So for the example above the SummaryTable would look like this
Item Code
Num Orders
I-001
3
I-002
2
I-003
1
Can someone please give me some guidance on how can I write a query to create this new table for me?
Thanks
Select your table using data...from table/range... to get it into powerquery
In powerquery
right click the Item Code column and choose Group by...
It should default to doing a count. You can change the name of the column from Count to Num Orders if you want. Then Hit Ok
The do File .. close and load to ... and decide how you want to get the data back into Excel. There is an optional [x] checkbox to add the data to data model

Spreadsheet - query-importrange sort by date and keep text in the same column

I am using 3 different spreadsheets which i have linked to a third spreadsheet where it shows up specific columns shorted by date asc (col2). The problem is that in the initial spreadsheets (where i importing the data from) the col30 (which i am trying to sort as col2 in final spreadsheet) has dates and text. What i need is that in the final spreadsheet to have the date sorted and to show also the text (in the col2 of final spreadsheet-which imports data from col30 of the 3 different spreadsheets).
The dates are sorted but neither the text appears nor the rest of the data which are in the same row with the date (on initial spreadsheets). The total data of the columns chosen when "Col6 CONTAINS '"&$B$1&"' are only appears when i put a date on col30 on initial spreadsheets. Otherwise, when it is no date but onlly text on col30 it doesn't return any variables.
Any suggestions? Thank you in advance.
What i have tried so far, which works without showing the text that i need to be shown:
=QUERY(QUERY({IMPORTRANGE("url1 ";"sheet1!A2:AJ1000");IMPORTRANGE("url2 ";"sheet2!A2:AJ1000");IMPORTRANGE("url3 ";"sheet3!A2:AJ1000")};"Select Col5,Col30,Col31,Col21,Col22,Col23,Col24,Col34,Col35,Col36 where Col6 CONTAINS '"&$B$1&"'");"Select * where Col2 is not null order by Col2")
Here is what I believe you are trying to achieve:
=QUERY(
{
IMPORTRANGE("1usAXftvFrpCHz7LN43avWrWqSIO14iKM-pgwuG9jMeE";"Sheet1!A2:AJ")\
ARRAYFORMULA(
TO_TEXT(
IMPORTRANGE("1usAXftvFrpCHz7LN43avWrWqSIO14iKM-pgwuG9jMeE";"Sheet1!AD2:AE")
)
)
};
"SELECT Col5,Col37,Col38,Col21,Col22,Col23,Col24,Col34,Col35,Col36 WHERE Col6='"&$B$1&"' AND Col37 is not null ORDER BY Col30, Col31"
)
Let's unpack the changes:
Remove the outer query. You don't need it. Instead add the condition and order by in the first query.
change the range to be an open ended one
Add columns with the text version of the dates / times.
The last point is important as query only supports a single type at a time. This means that when you were querying over the date and time, you were loosing the text (because they are of another type). Adding 2 more columns and forcing them to be text allows you to add them in the result without loosing information and keeping the originals allows you to order by them.
References
QUERY (Docs editors help)
TO_TEXT (Docs editors help)
ARRAYFORMULA (Docs editors help)

Instead of selecting a column to sort a table by in a dropdown, how do I add the sorting column names in a separate column?

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.

Datameer - Add Columns to Joined table

I have joined some data from HDFS with some data from an Oracle DW, which is working fine, but I cant seem to add any new columns to this sheet. To add columns for calculated fields etc I have to duplicate the sheet and do it there - this doesn't seem overly efficient.
Am I doing something wrong here or can you not add columns to a join result sheet?
... but I cant seem to add any new columns to this sheet.
Right. It will not be possible to add columns to a JoinedSheet. It is a new data set containing columns from two or more sheets based on a key column which you defined.
... or can you not add columns to a join result sheet?
It will be necessary to reference these data as input for a new Worksheet by Duplicating Worksheet.
Another approach could be using datameer rest-api. You can get the content of the workbook in json format and add columns manually or by implementing a simple script, then update the workbook with changed json file.

Resources