Forum Discussion

avioti's avatar
avioti
Frequent Visitor
9 years ago
Solved

Public Holiday - Script

Hello Guys

 

I have a Calendar Table and i would like to add a collumn which contains all public holidays.

Is there some script which i can use to generate it?

 

Thanks

  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi avioti,

     

    Current power bi not contains any script to auto generate the holiday calendar table.

     

    You should get a holiday list first, for example:

    1. Find out a public holiday list from web, import it to power bi.


    2. Create a calendar table and build the relationship.

    DateTable = ADDCOLUMNS(CALENDAR(DATE(2015,1,1),TODAY()),"Year",FORMAT([Date],"yyyy"),"Month",FORMAT([Date],"mmmm"),"Quarter",FORMAT([Date],"q"),"Week",WEEKNUM([Date],1),"Day Of Week",FORMAT([Date],"dddd"))

     

    3. Add calculated column to check relationship.(holiday = normal holiday + public holiday)

    Holiday Tag = IF(ISBLANK(RELATED(Holiday[Federal holiday]))=FALSE(),RELATED(Holiday[Federal holiday]),if([Day Of Week]="Saturday"||[Day Of Week]="Sunday",[Day Of Week],BLANK()))

     

     

    BTW, you can also share your requirement to ideas.

     

    Regards,

    Xiaoxin Sheng

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi avioti,

     

    Current power bi not contains any script to auto generate the holiday calendar table.

     

    You should get a holiday list first, for example:

    1. Find out a public holiday list from web, import it to power bi.


    2. Create a calendar table and build the relationship.

    DateTable = ADDCOLUMNS(CALENDAR(DATE(2015,1,1),TODAY()),"Year",FORMAT([Date],"yyyy"),"Month",FORMAT([Date],"mmmm"),"Quarter",FORMAT([Date],"q"),"Week",WEEKNUM([Date],1),"Day Of Week",FORMAT([Date],"dddd"))

     

    3. Add calculated column to check relationship.(holiday = normal holiday + public holiday)

    Holiday Tag = IF(ISBLANK(RELATED(Holiday[Federal holiday]))=FALSE(),RELATED(Holiday[Federal holiday]),if([Day Of Week]="Saturday"||[Day Of Week]="Sunday",[Day Of Week],BLANK()))

     

     

    BTW, you can also share your requirement to ideas.

     

    Regards,

    Xiaoxin Sheng

    • Joannec's avatar
      Joannec
      Frequent Visitor

      Hi - I know this is not a recent post - but I found the solution whilst searching for an answer to an issue I had, and it has helped me out with what I needed to do. Thanks for the solution and for posting!

  • dkay84_PowerBI's avatar
    dkay84_PowerBI
    Microsoft Employee

    I recommend just finding a web based source, based on your country, where you can pull in a table of dates that are holidays and then merge this with your existing date table.