How do I pivot (longer) Excel data with multiple header in R (Tidyr) - tidyr

I am trying to automate my analysis with Shiny but my source data in Excel comes in multiple headers as shown in the picture. How do I pivot this data to get it tidy in R with the Tidyverse? I have tried pivoting longer but I could do that only if the header is one row and not multiple rows headers. Unpivoting in Power Query is a bit similar to what I want to achieve in R Tidy. Multiple header sample data

Related

How to handle SSIS solution with an excel source having multiple headers

I am working on a package that requires I import an excel sheet with multiple headers. I am suppose to unpivot the top column (top header) and make that a row and also unpivot some columns in the actual bottom columns.
I have created the package using just the actual bottom columns. I then hard coded the top column into the table using derived column.
Here's an example of what I am looking for
Sample Raw Data and Target Result
You are trying to un-pivot or reverse-pivot the input. In SSIS you can use the unpivot transformation,
Shared a good walkthrough below, hope this helps.
https://www.sqlshack.com/an-overview-of-ssis-pivot-and-ssis-unpivot-transformation/
KR,
Alex

ETL transpose and cross join part of a table in SQL or Excel

I have an Excel spreadsheet that I need to import into a database. The data in the spreadsheet is of the following format.
I want to transform the 10 Wk columns into two columns: Week and Value. An example of this transformation I'd like is below (this is just the transformation of the first 3 rows in the table above).
Does anyone have any tips on making a transformation like this (either in SQL or Excel)? Ultimately I need to come up with a process to take the data from the spreadsheet of the format in the first table, transform it to look like the second table and load it into a Teradata database. I'm open to doing the transform process using SQL code, Excel or even Python code. Any help/suggestions is much appreciated. Thank you in advanced!

row header in mdx queries

Can anyone explain how to add row headers to the following query? I'm sure there is a way, surprised that the column headers appear but the row headers are null.
By row headers I mean the top of the returned data, in gray that actually shows the name of the row returned.enter image description here
That is SSMS and the way it displays the data.
In MDX Studio we get this:
...but SSMS and MDXStudio are not front end clients so this is just the way they have been designed.
If you are using say Excel as a front-end then you will maybe use a pivot-table to display the data - column headers will be the same as any other pivot table
If you are using SSRS then you can name the columns in your Datasets.
Other front-end clients will deal with this differently.

Set order of rows in Pivot Table with VBA

I am currently using a Pivot table which is linked to several tables in other sheets in a workbook. However I need to the rows to be ordered as per the Hierarchy I determine when I enter the data. I have the position number in one of the source tables but need to use that data to set the position within the pivot table using some VBA code. I'm not sure if this is possible so any thoughts are appreciated.
Thanks in advance.

.NET Winform - Pivot Table for multiple Data Value columns

I need to create a pivot table at the front end after retrieving data from the DB in a datatable and need to update the values of my grid with this data.
I have gone through many articles/blogs but they all demonstrate it by using one Data Value column. But in my scenario, I have 8 Data value columns to be pivoted.
Data To Pivot
Pivoted Data
Do someone has idea how to do it efficiently at the front end?
Would it be a good idea to embed the data in excel, create the Pivot there and retrieve the required data from excel?