Power Query - Modify tables before combining them - powerquery

On my table (point1) I am trying to get, that for each table of the grouped rows (point 2) I will have new row inserted (point 3) at the beginning of each table with the value in the column "Metadata1" equal to value form "Column2" for original row number 2 (starting counting from 0).
Link to excel file:
https://filebin.net/cnb4pia0vvkg937g

Its hard to know how much of your requirement is generic or specific, but
TransformFirst = Table.TransformColumns(#"PriorStepName",{{"Count", each
#table(
{"Column1","Column2","Metadata1"},
{{_{0}[Column1],_{0}[Column2],_{2}[Column2]}}
) & _
}}),
Together=Table.Combine(TransformFirst[Count])
in Together
modifies all the tables in column Count to include an extra row that is made up up Row0/Col1 Row0/Col2 and Row2/Col2
It then combines all those tables into one table

Related

How to add additional column showing sheet names & row source in query importrange function (google sheet)

I have a query importrange function to combine hundreds of my sheet into 1 new googlesheet file, but i need an additional column which show sheet/tab source name and the row source.
this is my query so far :
=QUERY(
{IMPORTRANGE("SheetID-1","Sheet1!A5:Y1000");
IMPORTRANGE("SheetID-2","Sheet2!A5:Y1000");
IMPORTRANGE("SheetID-3","Sheet3!A5:Y1000")},
"SELECT * WHERE Col2 IS NOT NULL Order By Col1", 0)
my query is like that (but for hundreds different sheet) and now i hope i can added aditional column in column Z that showing the source tab/sheet name with row :
Example :
Column Z : Sheet1 - Row 7
If i using filter i can add the additional column with the source row & sheet name like that, but im have no idea to add the column using query. Need some help here.

Tips to sum values and ignore all filter but the fields of two table in Dax?

I have 3 dimensions tables and one fact Table Sales
DimCalendar (Fields Year/Month/Day/Week)
DimCountry (Field : CountryName)
DimManager (Field ManagerName)
FctSales (Field : Amount)
I want to create a measure to Sum the Amount of the Sales (FctSales) and filter only to the fields of the tables DimCalendar and DimCountry.
After research, i was thinking about the function AllExcept, like :
CALCULATE(SUM(Sales[Amt]);ALLExcept(Sales;Country[Country];Calendar[Year]...)
but if i do that, i will have to write every columns of the table Calendar and Table Country in the AllExcept, i am wondering if there is another solution.
Maybe using REMOVEFILTERS() to remove every filter and then put back the filters over DimCountry and DimCalendar might work?
CALCULATE (
SUM ( Sales[Amt] );
REMOVEFILTERS ();
VALUES( DimCountry[CountryName] );
VALUES( DimCalendar[Date] )
)
DimCalendar[Date] should be the column used for the relationship with Sales.
This measure first evaluates the filter arguments in the current filter context.
Using as filter the columns used for the relationships guarantees that whatever the column used for filtering this would be mapped over the relationship.
Then, the REMOVEFILTERS() will remove any existing context filter and eventually the filter arguments evaluated during the first step will be applied, putting back any filtering that was set over DimCalendar and DimCountry.

How to auto-create row space / spacial definition between rows with different column values?

I want to create a row, or some kind of definition, between Google Sheets rows whenever one of the value in my columns contain a new / different value.
Here's an example of the kind of spreadsheets I'm putting together, which shows how Agencies are listed in Column A, and Sub-Agencies are listed in Column B.
I'd like to create some kind of row space / spacial definition between every new / different Sub-Agency, which are values that I enter in Column B of my spreadsheet -- but no space between rows with the same Sub-Agency value. Here's an example of the kind of row space / spacial definition that I'm seeking.
Any ideas / suggestion on how do this?
Many thanks for your help!
You can insert a row after X condition.
Using insertRowAfter(afterPosition) inserts a row after the row you want:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// This inserts a row after the first row position
sheet.insertRowAfter(1);

Append two tables with different sizes

I have table one with 5 columns and table two with 7 columns.
How can I append them into a new table with only the common columns (that is, the columns with common names)?
I tried all sorts of "Append Queries" in the Query Editor but it seems that it only works with exactly identical tables.
In DAX, UNION seems to have the same limitation.
Use Append Queries -> Append as New to create a new table.
The M function, Table.Combine(), will combine the columns where they are named the same and add columns with null values where they only exist in one table
Table.Combine({
Table.FromRecords({[Name = "David", Phone = "01235667886"]}),
Table.FromRecords({[Email= "me#gmail.com", Phone = "01124892522"]})
})
> Name Phone Email
> David 01235667886
> 01124892522 me#gmail.com

Extracting positions 1 to 11 and position 13 from a 15-digit number/string in Oracle

I have a 15-digit number that needs to be stored in an Oracle table either as a number or as a text.
Will I be able to select records from the table based on the field ("Positions 1 thru 11" + "Position 13")?
Example: If the data is 123456789012345, I need to select rows from the table to extract all rows that contain value "123456789013" in that field.
Can an index be created in Oracle to ensure the above query performs as good as a normal select query on the entire data field.
If you are storing the column in text then something like this should solve your problem. Use the first if you need to query separately otherwise if you want to query on first eleven and thirteenth use the last example.
create index ix_firsteleven on TABLE (substr(COL, 1, 11))
create index ix_thrirteenth on TABLE (substr(COL, 13, 1))
or
create index ix_concatstr on TABLE (substr(COL, 1, 11) || substr(col_name, 13, 1))

Resources