Data Warehousing and Data integration

Pivot in a report with dynamic columns

More
4 years 3 months ago - 4 years 3 months ago #21690 by Vassalli
I am in need to create a report with dynamic columns.
The columns are weeks number, starting from actual week (12-2022), going back for 52 weeks (13-2021) in a rolling year way.
The report will be executed once per week, so next week I'll have 13-2022 up to 14-2021 and so on.
Data comes from some columns:
External consultant in charge of a customer, name of the customer, name of the person of the customer who provided an order, weeks number, year number, email address, day of the order (for this field duplicates are admitted).
I am in need to have the number of the orders done each week, using a normal sql count.
I can eventually create a pivot with rolling week numbers, with some code like that:
select * into tab from cust_table
declare @sql nvarchar(max), @cols varchar(max)
select @cols = coalesce(@cols + ',', '') + ''
In this case I should create a variable and use those variables (52, like the number of the weeks in a year) and define them.
Is it there any more simple solution?
Thank you! :)
Last edit: 4 years 3 months ago by Vassalli.

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago - 8 months 5 days ago #21691 by admin
When you say report do you mean this kind of report?

www.etl-tools.com/wiki/advanced-etl-processor/advanced/reports/

Mike
ETL Architect
Last edit: 8 months 5 days ago by admin.

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #21692 by Vassalli
Yes Mike,
unfortunately I am in need to create a pdf report for each of my colleague and send it via email. :(

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #21693 by admin
Looks like an interesting challenge ;-)

Can you prove us with some examples, please

Here how my source data looks like (excel file)
And here is what I am trying to create (excel file)

Mike
ETL Architect

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #21694 by Vassalli
Perfect, I'll try to create a test environment. And I'll give you some excel files. :)
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #21696 by Vassalli
Hi Mike,
here it is: it's an excel file with a pivot inside.

db is the database, while sheet 1 is the graphical representation of the database that I would like to get.

Each "Representative" should receive it's own subset of data in a pdf, once per week, and the row containing week numbers should be desc (current week is the first, last week is current week+1 of the last year).

Thank you! :)
Attachments:

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save