Creating a simple date table in Power BI

Поделиться
HTML-код
  • Опубликовано: 30 июл 2024
  • This video shows how to build a basic date table using a calculated table and DAX. Article and download: sql.bi/137725?aff=yt
  • НаукаНаука

Комментарии • 127

  • @atiry839
    @atiry839 4 года назад +8

    A really simple way to explain with useful tips especially the last tip, thank you, Alberto!

    • @gruffalocrumble494
      @gruffalocrumble494 3 года назад

      Agreed. The last tip was surprising to me, and very helpful. I’m so glad I stumbled on your channel

  • @MrAbiliotiago
    @MrAbiliotiago 3 года назад +2

    Simple and practice explanation. One more outstanding material from SQLBI.

  • @abiscaia
    @abiscaia 2 года назад +2

    So simple and focused way to pass valuable information. Alberto, Thank you so much for your detailed explanation. Grazie!

  • @tyronefrielinghaus3467
    @tyronefrielinghaus3467 4 месяца назад +1

    I love the way he zooms into relevant parts....really, really helps. Thanks!

  • @graemegourlay2850
    @graemegourlay2850 2 года назад +1

    Great tutorial, I'm off to use this. For anyone else watching this.....watch to the end. I didn't know about marking the date table as "Mark as date table"; worth watching all the way through to observe this point.

  • @Amythyst34
    @Amythyst34 5 месяцев назад +1

    Very helpful video! You explain everything very well, so it can be understood and manipulated for the user's own data structure / needs. I appreciate that, since a lot of tutorial videos don't explain things well, and just expect you to copy what they do (which isn't helpful for applying in your own projects). Thank you!

  • @humayunshahzad9181
    @humayunshahzad9181 2 года назад +1

    Thankyou Alberto, I am new to powerBi but your assistance is very valuable in this.

  • @nikolaidedenkov8414
    @nikolaidedenkov8414 4 года назад +1

    Thank you, very clever yet simple way!

  • @toulasantha
    @toulasantha 3 года назад +1

    Great stuff mate. Sweet n short videos...
    How did I not come across your videos before? 🤔
    Keep up the good work.👍

  • @visalatchy_IT
    @visalatchy_IT 3 года назад +2

    Excellent tutorial!! perfect and clear explanation with examples.. Thank you!! Subscribed!!

  • @hulem98
    @hulem98 3 года назад +2

    Now I can customize our date drill down. Week, weekday, etc,.
    Thank you very much

  • @mathew9665
    @mathew9665 4 года назад +2

    SQLBI are the answer - Nice, concise and useful - thank you

  • @omiegawrd4841
    @omiegawrd4841 2 месяца назад +1

    Absolutely perfect explanation. Clarified so much. Thank you!

  • @niavras
    @niavras 3 года назад +1

    Great video, as always! Thank you !

  • @juliofidelsupokrauchinaide1225
    @juliofidelsupokrauchinaide1225 3 года назад +1

    Your explanation is the best. Thanks u!

  • @vladsamoilov9905
    @vladsamoilov9905 4 года назад +1

    Awesome tip, thanks Alberto

  • @praveensebastian2107
    @praveensebastian2107 Год назад +1

    Clear and simple. Thank you

  • @l3ol3lca
    @l3ol3lca 3 года назад +1

    Very helpful as always, thanks!

  • @sapnaroy6373
    @sapnaroy6373 3 года назад +1

    Wonderfully explained!

  • @maryamseidnejad3280
    @maryamseidnejad3280 3 года назад +1

    It was a great explanation. Thank you!

  • @nataliamunoz3089
    @nataliamunoz3089 8 месяцев назад +1

    Great and clear explanation. Thank you very much!

  • @pablofranciscodelamotatori9180
    @pablofranciscodelamotatori9180 22 дня назад +1

    Thanks a lot for sharing this content about date table in PowerBI.

  • @krishnakishorepeddisetti4387
    @krishnakishorepeddisetti4387 3 года назад +3

    Just one word..."awesome" 🙂

  • @anjpunk
    @anjpunk Год назад +1

    Short and Sweet, Love it.

  • @labzaper
    @labzaper 3 года назад +1

    This is great! Great resources

  • @mikeycbd
    @mikeycbd 11 месяцев назад +1

    Thank you from Melbourne, Au. 😀

  • @nidhalmahjoubi7964
    @nidhalmahjoubi7964 2 года назад +1

    Thanks a lot, very helpful!

  • @kamaur01
    @kamaur01 Год назад +1

    This was really helpful. Thank you

  • @enricomaciel
    @enricomaciel 4 года назад

    Good explanation! 👍

  • @sagarbhowal9016
    @sagarbhowal9016 2 года назад +1

    simply awesome !!

  • @julianmsocolovsky1852
    @julianmsocolovsky1852 11 месяцев назад +1

    Thanks! Very clear

  • @denizgurbuz3590
    @denizgurbuz3590 2 года назад

    Very informative as always, Thank You Mr. Alberto. I am about to create an hourly task table, like a step counter in hour basis or counting the customers in the gym in hourly distribution. Do you have any related video for this? Thank you again for your focused and easy understanding videos.

    • @SQLBI
      @SQLBI  2 года назад +1

      No, but thanks for the request - it's in our backlog!

  • @vikasyaduvanshi2222
    @vikasyaduvanshi2222 2 года назад +1

    Well explained Sir Thanks for your Help

  • @phorton968
    @phorton968 4 года назад +1

    Gold standard!

  • @leonardoolivaro5230
    @leonardoolivaro5230 3 года назад +1

    Thanks! Really usefull

  • @DIGITAL_COOKING
    @DIGITAL_COOKING 4 года назад +1

    Very good explanation

  • @mikem2246
    @mikem2246 2 года назад +1

    Thanks for the interesting video. I want to notice that this scenario is not relevant where the target table is involved in the model.

  • @vsr1727
    @vsr1727 4 года назад +1

    Thank you

  • @stefanopalliggiano6596
    @stefanopalliggiano6596 2 года назад

    Thank you for the video. I have a question: when I add a "Quarter" column, as you have shown in the video, suddenly my dates are restricted and start from 01/07/2021 (Start of Q3) and end 31/01/2022 (end of Q1). When I delete the line in the DAX code that generates it the "Quarter" column, my dates start on 01/01/2021 and end 31/12/2022. This makes more sense, because the dates in my table span 2021/2022. Any idea of why adding a "Quarter" column behaves that way?

    • @stefanopalliggiano6596
      @stefanopalliggiano6596 2 года назад +4

      Actually, I think I have sorted it. It simply shows all the dates sorted by quarter, so Q3 will contain both dates for 2021 and 2022.

  • @Sergio-td7mn
    @Sergio-td7mn 2 года назад +1

    To "mark as a date table" was a very important hint

  • @user-vz8dq1nk6j
    @user-vz8dq1nk6j 11 месяцев назад +1

    thank you!!

  • @Quidisi
    @Quidisi 4 года назад +2

    Thank you for this video!
    Do you know why Power BI ships with such a limited default date table?
    Also - I assume we will have to do this for every PBI project, or can this be made part of the default PBI template?
    Again - thanks so much for so clearly explaining this.

    • @marcorusso7472
      @marcorusso7472 4 года назад +2

      You can create your own template to create a new Power BI project - just create a Date table and save it as a PBIT file. You can find a more complete (and complex) Date table at www.sqlbi.com/tools/dax-date-template/

    • @Quidisi
      @Quidisi 4 года назад

      @@marcorusso7472 Thanks!!

  • @Reviews365
    @Reviews365 3 года назад +3

    This was an excellent video Alberto! Just one question, my company has accounting periods which go from 1-16 (13-16 are accounting adjustments for year end), please could you help so in the calendar the date for eg period 16 would still be 31/12/YY, I guess calendar month would be 12 but period would be 16. Please could you help clarify how to capture this in Dax as another column?

    • @SQLBI
      @SQLBI  3 года назад

      You might want to check the Time Intelligence patterns here: www.daxpatterns.com/time-patterns/
      The month related calculation pattern also shows how to manage calendar with more than 12 periods per year.

  • @balaji_906
    @balaji_906 3 года назад

    Super !!

  • @emirtahiri1949
    @emirtahiri1949 2 года назад

    Ciao Alberto! One question If I may.. In case I update my main data table with new entries, does my date table update itself automatically?

  • @meetdenis82
    @meetdenis82 3 года назад

    Very good explanation. Is it preferred to create a date table in Power BI and not in Power Query Editor? What would you suggest?

    • @SQLBI
      @SQLBI  3 года назад +1

      You can create the Date table in Power Query, there are no differences in the final result.

  • @chandanverma4336
    @chandanverma4336 3 года назад +1

    bahut jabardast

  • @sonpurkesone4072
    @sonpurkesone4072 Год назад +1

    Super helpful

  • @christianpiazza9690
    @christianpiazza9690 Год назад

    For whatever reason, when I add the new ‘Date’ table fields into my table with the field of data I am attempting to summarise by year and month - the year and month fields are blank. Can you advise where I may have gone wrong?

  • @vida1719
    @vida1719 4 года назад +1

    It is amazing what can be created with DAX. Regarding performance, what is more efficient DAX or M code to create a date table?

    • @marcorusso7472
      @marcorusso7472 4 года назад

      See my answer to a similar question in this same page!

    • @albertoferrari6893
      @albertoferrari6893 4 года назад +1

      No difference, choose the one you prefer

  • @ZOOTOPIAAAA
    @ZOOTOPIAAAA 9 месяцев назад

    so does the calander auto date that u create have the same value as the order date or u just create new date ??thank you sir
    .

  • @michaelwu1555
    @michaelwu1555 4 года назад +1

    What would be the better method to create a date table, through DAX or Power Query?

    • @marcorusso7472
      @marcorusso7472 4 года назад

      See my answer to a similar question in this same page!

  • @szechingbong9857
    @szechingbong9857 2 года назад +1

    Thank you for this videos. Could I know how to write DAX to include Public Holidays as non working days?

    • @SQLBI
      @SQLBI  2 года назад

      See examples in DAX Date Template: www.sqlbi.com/tools/dax-date-template/

  • @Pedro_Israel
    @Pedro_Israel 2 года назад

    It is much more easier with Pivot in Excel. You just put the option to create a standard date table and it has most of the useful columns.

    • @SQLBI
      @SQLBI  2 года назад +1

      You can also use Bravo as an external tool in Power BI now - there is a feature that is also more flexible than the one in Excel: bravo.bi/

    • @Pedro_Israel
      @Pedro_Israel 2 года назад

      @@SQLBI Thank you, I found later about Bravo, its a great tool.

  • @racerx1326
    @racerx1326 Год назад

    How do you indent formulas in the formula bar? Tab usually autocompletes the formula.

    • @SQLBI
      @SQLBI  Год назад

      SHIFT+ENTER goes to a new line following the formatting rules.
      Select a section, press TAB or SHIFT+TAB to indent/unindent the code.

  • @SalisSyed
    @SalisSyed 4 года назад +1

    I heard many recommending building date table with power query instead of DAX. What is the best approach in general?

    • @marcorusso7472
      @marcorusso7472 4 года назад +3

      There are no differences at query time. The Power Query approach requires knowing the range of years to use in advance, the DAX approach can retrieve it from the imported table in a very quick and easy way. However, there are no particular pros/cons of using either one or the other. One annoying UI issue we have today in Power BI Desktop is that every time you click on a column of a calculated table, you see the definition of the table in the formula bar - but I hope this will be fixed in upcoming versions of Power BI Desktop. You do not experience this problem if you publish the Dataset in a PBIX file and then create your reports referencing the published Dataset from separate PBIX files.

    • @albertoferrari6893
      @albertoferrari6893 4 года назад

      The one you like the most. I prefer DAX, but it is really a matter of personal taste. Power Query works totally fine too.

  • @NyeinChanAung99
    @NyeinChanAung99 Год назад

    Is there anyway I could load existing calendar table from SQL server using the date range of our data date (I.e. to store the max and min date as parameter values after loading the dataset and pass these date in a query to load the date dimension table). The reason is that all the bank holidays are always up to date in our SQL table, so we will not need manual adjustment when there is an additional bank holiday.

    • @SQLBI
      @SQLBI  Год назад

      You should move the filter to power query (M) and it would be more expensive to find the date range that way. An alternative is to always load the SQL table in a hiddent table in Power BI and copy only the range of dates you need in a calculated table in DAX; which could apply the same technique.
      However, take a look at Bravo bravo.bi which has a more advanced technique to create date table that include holidays.

  • @simonq2770
    @simonq2770 Год назад

    What is better to create a date table in power query or create a date table with Dax. Which is better performing dax or power query?

    • @SQLBI
      @SQLBI  Год назад

      It depends. Use what you are comfortable with!

  • @riazahmedshaik
    @riazahmedshaik 3 года назад

    Hi,
    I'm very new to Power BI. I have a basic question on date table. Why do we need a date table to use time intelligence functions in Power BI? Why can't we use the existing date in the table (Eg: order date in this example) ?
    Thanks,

    • @SQLBI
      @SQLBI  3 года назад +1

      You can, but we suggest you not to do that, and to use a separate date table instead.
      Watch these videos to see why:
      ruclips.net/video/Bzruqrj-wZg/видео.html
      ruclips.net/video/xu3uDEHtCrg/видео.html

  • @user-uo8rs2yu7c
    @user-uo8rs2yu7c 2 года назад

    Thank you for the video! The question is - how to create separate date table while using Direct Query?

    • @SQLBI
      @SQLBI  2 года назад

      You either create a calculated table in DAX just as shown in the video, or you have to create a date table on your data source (e.g. SQL Server).

    • @user-uo8rs2yu7c
      @user-uo8rs2yu7c 2 года назад

      @@SQLBI the "Create table" button is greyed out. The reason is Direct Query. Thus, the only way is to create a date table on my data source?

    • @SQLBI
      @SQLBI  2 года назад +1

      It depends on version and other details. Try with Bravo for Power BI: bravo.bi

    • @user-uo8rs2yu7c
      @user-uo8rs2yu7c 2 года назад

      @@SQLBI thanks!

  • @lindalim9583
    @lindalim9583 5 месяцев назад

    I don't quite get the min date and max date part, are we supposed to key in something somewhere? The video doesn't illustrate this, we only have the code.

  • @chrisbroughton6
    @chrisbroughton6 Год назад

    What if I had more than one date in a single table? I can't create a relationship to both dates from the dates table as it can't filter both together

  • @steinarbreivik1895
    @steinarbreivik1895 2 года назад

    An interesting problem with a date table is that if you later need to add one or more SQL tables in Direct Query mode the add will fail. You have to delete the date table to be able to add more tables in Direct query mode. Just verified this now. Maybe it's a bug in PowerBI, I don't know. Any similar experiences out there?

    • @SQLBI
      @SQLBI  2 года назад +1

      In general, it is not a good idea to use a calculated table in DirectQuery for a Date table - you might want to create a Date table in SQL (using a view or a physical table) to avoid performance issues.

  • @sindhurakundavaram8152
    @sindhurakundavaram8152 2 года назад +1

    at 0:14 you say there are no dates, but the sales table has the OrderDate column?

  • @riazuddin7493
    @riazuddin7493 3 года назад

    How to create a date table when I have a date column with repeated values, I tried Calendarauto but received the error message "A table of multiple values was supplied where a single value was expected"

    • @SQLBI
      @SQLBI  3 года назад

      This should not happen - CALENDARAUTO creates a new table, are you saying that you have this error when you use CALENDARAUTO or in a following step? You probably get the error described because you provide the wrong Date column to a time intelligence function. You should use the Date column of the Date table, where the Date is unique. CALENDARAUTO creates a new table with unique Dates.

  • @h93slafco
    @h93slafco Месяц назад

    Hi, in 2:50 when Alberto adds Quarter the Date column starts not from Jan 1st, but from July 1st. Why? I tried today and got same result. Is this a bug or feature? I would be expecting when I add new column (Quarter) that the dates in table are not changed, in other words start from Jan 1st.

  • @user-po4jc4vf1g
    @user-po4jc4vf1g 3 года назад +1

    Hi, Alberto, Marco.
    Do you have a solution for custom date hierarchy, that is created from date table - to use it in a continuous mode?
    When I use "Auto Date/Time" - all is fine and I can simply resize a chart and no horizontal scroll, but when I try to use custom date hierarchy - only categorical mode allowed. Actually I need Year / Month / Day (the same as auto).
    Unfortunately it's impossible to use "as Date table" and "auto Date/Time" at the same moment.
    I tried to recreate columns with same type as in temp tables - but it's not working for me.
    Thanks a lot.

    • @SQLBI
      @SQLBI  3 года назад +1

      Follow the advices in this article+video:
      www.sqlbi.com/articles/creating-a-simpler-and-chart-friendly-date-table-in-power-bi/

    • @user-po4jc4vf1g
      @user-po4jc4vf1g 3 года назад

      @@SQLBI Thanks a lot. But even from you file, when I add a full hierarchy to line chart - it's turns into categorical and I see each date on a X-axis.
      Year-Month - as a single measure - OK, but traversing down from Year->Month->Day hierarchy turns into categorical. Auto Date/Time gives different result and I have no Idea how to make it same way

    • @SQLBI
      @SQLBI  3 года назад

      Did you try the right date? The file of the article linked before has different date tables showing different behaviors - you should try to change the "Type" from Categorical to Continuous in case the default is not correct.

    • @user-po4jc4vf1g
      @user-po4jc4vf1g 3 года назад

      @@SQLBI I think yes. I've attached a small gif with what I do and what I get. If you would have a time a have a look and tell what's going wrong, I would be very happy =) All fields are dates and combined in a hierarchy, but they are not working as expected
      drive.google.com/file/d/1spqcFbJIBjN0Iksg_sABXtafUnsOqfzW/view

    • @SQLBI
      @SQLBI  3 года назад +1

      You're right - they should have changed something since we published the article. We have to investigate more, I will keep you posted. The workaround is using the column *without* a custom format string - the presence of the custom format string seems to break the behavior we had before.

  • @JS-ts2vv
    @JS-ts2vv 3 года назад

    How do we handle multiple measures with different Time Dimension i.e. Order Date, Sales Date, Purchased Date etc., Is it possible to link multiple Dates attribute to this one Fiscal Date Table?

    • @SQLBI
      @SQLBI  3 года назад +1

      You can use multiple relationships and choose the active one with different measures or by leveraging on calculation groups (use USERELATIONSHIP in CALCULATE to switch to the relationship to use).
      See this: www.sqlbi.com/articles/using-userelationship-in-dax/ (article+video)

    • @JS-ts2vv
      @JS-ts2vv 3 года назад

      @@SQLBI that is definitely a great way to access the Date's table for multiple uses for sure.. thanks for sharing it and keep up the good work! I am a fan :D

  • @senthilramana
    @senthilramana 3 года назад

    Our Fiscal year is from Apr - Mar.
    Because of this the July month in your example falls in Q2 for us instead of the BI default Q3.
    Is there a way to change my starting quarter Q1 from April -May - Jun ?

    • @SQLBI
      @SQLBI  3 года назад

      You can find an example here: www.daxpatterns.com/month-related-calculations/
      A more complex/complete one here: www.sqlbi.com/tools/dax-date-template/

    • @meetdenis82
      @meetdenis82 3 года назад

      I have this situation as well. Our fiscal year is from Sep-Aug. I used calculated columns to configure which months fall in Q1, Q2, Q3 and Q4. You will need to write basic DAX though

  • @andrewyoung9180
    @andrewyoung9180 Год назад

    After I type in Date, so I hit enter?

  • @roopalityagi3958
    @roopalityagi3958 3 года назад

    is there any link to download the data model for practice purpose

    • @SQLBI
      @SQLBI  3 года назад

      Use the link to the article in the description of the video, you can download the file from that page.

  • @sbn4862
    @sbn4862 2 года назад

    Mr Alberto I have a question. Why when I create a month name by Format(Month=(date),"MMM") it returns only January and December ? There is't other month names. Only first and last month name in the created autocalendar

    • @SQLBI
      @SQLBI  2 года назад

      Strange, check your date table.

    • @sbn4862
      @sbn4862 2 года назад +1

      @@SQLBI It is a shame for me. i checked, instead of Format([Date],"MMM") I wrote Format(Month[Date],"mmm"),Thank you

  • @Golden_Tortoise
    @Golden_Tortoise 5 месяцев назад

    what do you mean provide the expression date? that is not explain thus, have no idea where and how [Date] was created and used here

  • @anaclaramedeiros4110
    @anaclaramedeiros4110 3 года назад

    Is not working for me :(. I created a date table so that I could join the dates from multiple sources and then use the date ( from my new date table) as a Slicer filter. The slicer shows me a date range from 1926 to the last day of 2020. Shouldnt only show me the dates within the range of my model? I doubled cheked and I have only dates between 01/11/2020 and 11/11/2020. Thanks

    • @SQLBI
      @SQLBI  3 года назад +1

      If you are using CALENDARAUTO, you might have a date column in some table - like Birthdate for example? CALENDARAUTO looks for any date column, you you want to restrict the search to a limited number of tables replace CALENDARAUTO with something like:
      FILTER ( CALENDARAUTO(), YEAR ( [Date] ) >= YEAR ( MIN ( Sales[Order Date] ) ) )

    • @anaclaramedeiros4110
      @anaclaramedeiros4110 3 года назад +1

      @@SQLBI sei fantastico, grazie mille per davvero. Saluti dal Brasile.

  • @GodParticleZero
    @GodParticleZero 3 года назад

    Why does calendarauto start from 1910 when my model has dates that only go back to 2014?

    • @SQLBI
      @SQLBI  3 года назад +1

      If you use CALENDARAUTO, any column with a date is evaluated. If you have a Birtdate column in some table, its range is considered, too. You can either use CALENDAR instead of CALENDARAUTO, or you can wrap CALENDARAUTO in a FILTER where you get rid of dates you want to ignore.

    • @GodParticleZero
      @GodParticleZero 3 года назад +1

      @@SQLBI Ah, that's what it was...a DOB in another table. I thought it was only pulling from my sales table. Thanks!

  • @info2satish
    @info2satish 3 года назад +1

    Enjoy DAX!!😀😂👍

  • @mathijs9365
    @mathijs9365 4 года назад +1

    Why isnt this standard in powerbi. Date table is something general

  • @anaclaramedeiros4110
    @anaclaramedeiros4110 3 года назад

    Couldnt find a solution on the web for my issue This time :I only brought to Power BI the dates from my model ranging between 1/11/2020 to 11/11/2020 ( I filtered the query I am using to source the data from my fact table in SQL server). In PBI I only selected one Date/time field in my table (callinititationts). Then I created a date table in powerbi: using DAX as shown in the video and the kind answer SQLBI gave me:
    Date =
    VAR Mindate = YEAR(MIN(All_Facts_Table[CallInitiationTs]))
    VAR Maxdate = YEAR( MAX(All_Facts_Table[CallInitiationTs]))
    RETURN
    ADDCOLUMNS(
    FILTER(
    CALENDARAUTO(),
    YEAR ( [Date] ) >= Mindate &&
    YEAR ( [Date] )

    • @SQLBI
      @SQLBI  3 года назад

      Use CALENDAR instead of CALENDARAUTO if you want a partial Date table.
      CALENDARAUTO always provide a complete year.
      However, if you don't have a complete year, Time Intelligence functions are not guaranteed to work correctly. If you don't use DAX time intelligence functions, then keeping an incomplete Date table does not have consequences.

    • @anaclaramedeiros4110
      @anaclaramedeiros4110 3 года назад +1

      @@SQLBI Perfect. Will try with Calendar then. Thank you so much!

  • @leonidasparigoris1389
    @leonidasparigoris1389 2 года назад

    But what about weeks?!

    • @SQLBI
      @SQLBI  2 года назад +1

      Plenty of content about that here: www.daxpatterns.com/week-related-calculations/

    • @leonidasparigoris1389
      @leonidasparigoris1389 2 года назад +1

      @@SQLBI Thank you sir. Great content always

  • @mikeycbd
    @mikeycbd 5 месяцев назад

    Back again... just updating my date table with the variables. It's a shame ruclips.net/video/OgD0NjKeWDU/видео.html has used YOUR code and getting clicks. Hopefully you have been notified by Google of copyright notification in the Copyright tab.

  • @teomano1
    @teomano1 2 года назад +1

    A very good explanation, thank you!