cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TCR_Carlsberg
Frequent Visitor

Create a new table based on start and end dates in my table

Hi All!

 

Will start by thanking you all on answering my previously questions! Big virtual clap on the shoulder.

 

The next problem I have is trying to create a graph over the numbers of campaigns per week.

This is my Campaign table:

image.png

As you can see I dont have one line per week just the start week and end week.

With this data I like to create a graph to compare the 2 years to eachother, like this:

image.png

To create this graph I faked the result table I need help with. The table I created by hand looks like this:

image.png

 

So does anyone of you have and idee how I can create my helper table from a combination of my Campaign table and mayby an Calender table?

Is there someway I can create the graph without my helper table just by creating measuers/columns?

 

I have used SUMMARIZE before to create tables but in this case I need multiple lines per week line and I cant get that with SUMMARIZE as I see it.

 

Kind regards,

Thomas

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Re: Create a new table based on start and end dates in my table

Hi @TCR_Carlsberg

 

Try this

 

Go to Modelling Tab>>>> NEW TABLE and enter this formula

 

NEW TABLE =
SELECTCOLUMNS (
    GENERATE (
        Campaign_Table,
        GENERATESERIES (
            CALCULATE ( VALUES ( Campaign_Table[StartWeek] ) ),
            CALCULATE ( VALUES ( Campaign_Table[EndWeek] ) )
        )
    ),
    "CampID", Campaign_Table[CampID],
    "CampName", Campaign_Table[CampName],
    "Year", Campaign_Table[Year],
    "Week", [Value]
)

 

Try my new Power BI game Cross the River

View solution in original post

6 REPLIES 6
McCow Resolver III
Resolver III

Re: Create a new table based on start and end dates in my table

Hi @TCR_Carlsberg

Are you alredy tryed CALENDAR function? Example:

Table = CALENDAR(DATE(2015;11;1);now())

Best regs

TCR_Carlsberg
Frequent Visitor

Re: Create a new table based on start and end dates in my table

I dont have any trouble creating a calender. I just cant use that to create a helper table.

This is how I created the Calender table I played with to try and solv this by myself:

Calendar = ADDCOLUMNS ( CALENDAR (DATE(2016;1;1); DATE(2018;12;31)); 
    "DateAsInteger"; FORMAT ( [Date]; "YYYYMMDD" ); 
    "Year"; YEAR ( [Date] ); 
    "MonthNo"; FORMAT ( [Date]; "MM" ); 
    "YearMonthNo"; FORMAT ( [Date]; "YYYYMM" ); 
    "YearWeek"; FORMAT ( [Date]; "YYYY" )&FORMAT(WEEKNUM([Date];2);"0#"); 
    "WeekNo"; FORMAT(WEEKNUM([Date];2);"0#"); 
    "Month"; FORMAT ( [Date]; "mmmm" ); 
    "Quarter"; "Q" & FORMAT ( [Date]; "Q" ); 
    "YearQuarter"; FORMAT ( [Date]; "YYYY" ) & "/Q" & FORMAT ( [Date]; "Q" ))

 

Kind regards,

Thomas

Super User III
Super User III

Re: Create a new table based on start and end dates in my table

Hi @TCR_Carlsberg

 

Try this

 

Go to Modelling Tab>>>> NEW TABLE and enter this formula

 

NEW TABLE =
SELECTCOLUMNS (
    GENERATE (
        Campaign_Table,
        GENERATESERIES (
            CALCULATE ( VALUES ( Campaign_Table[StartWeek] ) ),
            CALCULATE ( VALUES ( Campaign_Table[EndWeek] ) )
        )
    ),
    "CampID", Campaign_Table[CampID],
    "CampName", Campaign_Table[CampName],
    "Year", Campaign_Table[Year],
    "Week", [Value]
)

 

Try my new Power BI game Cross the River

View solution in original post

Super User III
Super User III

Re: Create a new table based on start and end dates in my table

@TCR_Carlsberg

 

1050.png

Try my new Power BI game Cross the River
Super User III
Super User III

Re: Create a new table based on start and end dates in my table

@TCR_Carlsberg

 

 

Please see the attached file here

(With your sample data)

 

Try my new Power BI game Cross the River
Highlighted
TCR_Carlsberg
Frequent Visitor

Re: Create a new table based on start and end dates in my table

That is a beautiful solution. Works like a charm in my test case. I'll try it on my complete dataset...

 

Thank you!

 

/T

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors