Extended Date Table (Power Query M function)

Hi @Melissa and @BrianJ

I’ve added ISO Quarters in the attached pbix. In the script itself (should you want to add it), here are the lines added:

// ---------------------------------------------------
    // ISO QUARTER: for Melissa to review before adding
    InsertISOQuarter = Table.AddColumn(InsertWeeknYear, "ISO Quarter", each if [ISO Weeknumber] <= 13 then "Q1" else if [ISO Weeknumber] <= 26 then "Q2" else if [ISO Weeknumber] <= 39 then "Q3" else "Q4", type text), 
    InsertISOQtrYear = Table.AddColumn(InsertISOQuarter, "ISO Quarter & Year", each [ISO Quarter] & " " & Number.ToText([ISO Year]), type text),
    InsertISOQtrnYear = Table.AddColumn(InsertISOQtrYear, "ISOQuarternYear", each [ISO Year] * 10000 + Number.FromText(Text.End([ISO Quarter],1)) * 100, Int64.Type),
// ---------------------------------------------------

.
ABOUT ISO Quarters
(just some additional info for everyone to read)

ISO-8601 calendars have a consistent number of weeks in each quarter and a consistent number of days > each week, making the ISO-8601 calendar popular when calculating retail and financial dates.

The first three quarters in the ISO-8601 always have 13 weeks in them, with the last Quarter having either 13 or 14 weeks in it, depending upon the start of the next ISO-8601 year.

https://help.tableau.com/current/pro/desktop/en-gb/dates_calendar.htm

Cheers, MichelleISO QUARTERS - added.pbix (91.8 KB)

2 Likes

Hi @michellepace,

Good to see you’ve solved that on your own :+1:

Thanks for posting your method, it’s similar to my approach… I’m going to review the full Date table M code this weekend, might do some other updates…

All the best.

5 Likes

@Melissa,

If making some revisions, please include Fiscal Day of Year , Fiscal Week of Year & Fiscal PYTD. I think those would be great additions. I currently do most of these as calculated columns, but know that Power Query is better suited for this.

Thanks
Jarrett

1 Like

Hello.
Thank you, the table is really powerful.
I copied and pasted the function in Power Query and tried to convert the column “Month & Year”, which is generated automatically, into Date format. It worked fine, except for the month of “March” . I can see that it gives me an error for March only for all the years.
I have a file with Monthly budget data (month and year) and I’m trying to link the DateTable with these dates via TREATAS function. Works fine, but it excludes the month of March.
Can anyone help me on this?
Thank you very much.

Marco

1 Like

Hi @marcoercolani
I would recommend that you start a new posting as this posting is already solved.

thanks

1 Like

This calendar is fantastic, thank you!

How do i add the following coloumns please?

Yesterday
Today
Past 7 days
Current month
Current fy qtr
Current fy

Basically, i want my dashboard to have those filtered dates to filter through all of my dashboard. Thanks in advance

@Melissa @BrianJ

1 Like

Hi @BI_Noob_Forgiveme,

That sounds more like a Dynamic Date range slicer…
You’ll find all about that here.

I hope this is helpful.

1 Like

Ok thanks @Melissa, will read up about it then copy your code. Seems a bit complex for my bi noob brain. So I’m using the date table from this original post, do i then create 2 more tables using your code?

1 Like

Hi @BI_Noob_Forgiveme,

Further down in that tread you’ll find a single query example.
Use which ever method you prefer, the result is exactly the same :smiley:

if you need assistance, please create a new topic, provide a sample PBIX and a description of your requirement. Thank you!

1 Like

Ok thanks, will give it a try first to see what works. Thanks heaps @Melissa

1 Like

@Tibbie,

Use Quarter Offset column. Current Quarter will = 0. If that is not what you want, please create another thread with your question.

Thanks
Jarrett

2 Likes

Hi @Tibbie,

This Date table includes both IsCurrentFQ and a QuarterOffset column.
So you should have everything you need…

Like @JarrettM already mentioned if you have an additional question, please create a new topic.
Thanks!

2 Likes

Sorry, i did not see them in the sea of columns. Thanks for the help!

1 Like

@Melissa,

I used in the past prior versions of this Date Table which has been significantly improved thru time.

Why is it that in the first post within this thread you were covering how to convert it from a function to a true table (hence allowing modification using the PQ bar) whereas now I have the feeling you’d recommend users to use the function table instead - is my understanding correct?

I’m attempting to convert this function Date table into a table but struggling a bit due to the immense code that has been added (specially not sure how to treat the documentation part of it).

Thanks a lot

1 Like

Hi @SamSPAIN,

For “ease of use” just use the Date table M function as a function. However should you need to make modifications, turning this function query into a table query is extremely helpful.

I understand that with all the updates, it has become a bit more difficult to translate the instructions given for that proces, so I have updated the image in the initial post above.

I hope this is helpful

3 Likes

Love this date table and the thread, great example of a great community!

I started using it for all my new reports a few months back and trying to go through my old reports to update those also. I love going through the process of making the start and end dates dynamic.

Setting Up A Dynamic Startdate And Enddate For Power Query Date Tables (enterprisedna.co)

2 Likes

Hi @Melissa,

Thanks a lot for your reply. I was trying do that and got some errors - see below:

Yesterday night I went thru the whole thread and I would swear there was 2 videos of yours, being the first one used to showcase how could we convert from fx to tables (the second one is the one currently being shown in this thread - to remove/adjust columns in the Advance Editor). If I remember this video well, you had to rename the first variable (StartDate) and had to use it further down in the code to make it work - am I correct?

If you could please be so kind to publish again the first video converting from fx to table that would be great.

Last but not least, I think there’s no WeekNum (1, 52…) in the code (there’s the ISO Weeknumber though) - unless I’m missing something. If we could have this too that would really improve.

Much appreciated

1 Like

Hi @SamSPAIN,

You are missing a closing parenthesis in the EndDate variable declaration.

I removed the link to the video on how to turn your function query into a table query because it no longer matches the image in the initial post above, which could be confusing. You can find that here.

I think you might be referring to this video…

This is an ISO-8601 calendar. But you can make your own modifications and/or additions of course.
These ISO-8601 week attributes are currently included.

3 Likes

Superb @Melissa! Thanks so much! Yes I agree, I have calculated WeekNum myself quite easily using Power Query ribbon functions which for newbies like I is far way more intuitive :slight_smile:

PS. this calendar is massive

1 Like

Massive & awesome :wink:

If you find the data table has too many columns, use Chose Columns at the end to just leave what you need. That’s what I’ve done with a few of my reports. Stripped them down to only the columns I require.

2 Likes