📔
TPW Staff Resources
  • About This Wiki
  • Staff Resources Read-Only
  • General
    • Acronym Lookup
    • Technology Service Requests
    • UKG Timesheets
  • Video, Chat, and Collaboration
    • Microsoft Teams
      • Creating Meetings
      • Joining Meetings
      • Chat
      • Creating Teams
      • Teams Channels
    • Miro
    • Using Box.com to Share Large Files
  • Working Remotely
    • Getting Started (revise this..)
    • Citrix Receiver
      • Connect from Outside the COA Network
      • Connect from Inside the COA Network
    • NetMotion
    • GoToMyPC
    • Working Remotely from a Mac
      • Troubleshooting AnyConnect for macOS Catalina
      • Resetting Your Network Password from a Mac
  • Computer Management
    • Managing your Network Password
    • ANTI-VIRUS for Computers not Connected to the City’s Network
  • Phone Resources
    • Checking Voicemail | Non-COA phone
    • Checking Voicemail | COA phones
    • Masking personal phone number when calling external numbers
    • Display your COA phone number when calling from your cell phone
    • Phone Forwarding (EC500)
    • Phone Forwarding Alternative (Avaya OneX Communicator)
    • Avaya IX Workplace Setup and User Guide for Mobile Phone
    • Voicemail to Email (Avaya Unified Messaging)
  • Power BI
    • Getting Started
    • How-To
      • Access Power BI Premium Workspace
      • Create a new premium workspace in Power BI
      • Connecting to a Dataflow
      • Access On-premise Data Gateway
      • Publish public link for Power BI item
    • Handover Checklist
      • SMD Signs and Markings Performance Measures
    • Power Query and DAX Formulas
      • Calendar Table
      • Calculate Fiscal Year
      • Conditional Format using DAX
      • Percent Complete on Time
  • Solutions Menu
    • Offerings
    • Do you know about MS Forms?
    • Need a Smart form for public intake?
    • What can SharePoint do?
    • So you need a dynamic Report & Dashboard?
    • What we can build in Knack
    • Need a custom solution?
Powered by GitBook
On this page

Was this helpful?

  1. Power BI
  2. Power Query and DAX Formulas

Calendar Table

PreviousPower Query and DAX FormulasNextCalculate Fiscal Year

Last updated 1 month ago

Was this helpful?

Original DAX:

This is modified to reflect COA fiscal year starting in October 1st.

Date = 
//************** Script developed by RADACAD - edition: July 2021 
//************** set the variables below for your custom date table setting 
var _fromYear=2021 // set the start year of the date dimension. dates start from 1st of January of this year
var _toYear=2027   // set the end year of the date dimension. dates end at 31st of December of this year
var _startOfFiscalYear=10 // set the month number that is start of the financial year. example; if fiscal year start is July, value is 7
//************** 
var _today=TODAY()
return
ADDCOLUMNS(
    CALENDAR(
                DATE(_fromYear,1,1),
                DATE(_toYear,12,31)
),
"Year",YEAR([Date]),
"Start of Year",DATE( YEAR([Date]),1,1),
"End of Year",DATE( YEAR([Date]),12,31),
"Month",MONTH([Date]),
"Start of Month",DATE( YEAR([Date]), MONTH([Date]), 1),
"End of Month",EOMONTH([Date],0),
"Days in Month",DATEDIFF(DATE( YEAR([Date]), MONTH([Date]), 1),EOMONTH([Date],0),DAY)+1,
"Year Month Number",INT(FORMAT([Date],"YYYYMM")),
"Year Month Name",FORMAT([Date],"YYYY-MMM"),
"Day",DAY([Date]),
"Day Name",FORMAT([Date],"DDDD"),
"Day Name Short",FORMAT([Date],"DDD"),
"Day of Week",WEEKDAY([Date]),
"Day of Year",DATEDIFF(DATE( YEAR([Date]), 1, 1),[Date],DAY)+1,
"Month Name",FORMAT([Date],"MMMM"),
"Month Name Short",FORMAT([Date],"MMM"),
"Quarter",QUARTER([Date]),
"Quarter Name","Q"&FORMAT([Date],"Q"),
"Year Quarter Number",INT(FORMAT([Date],"YYYYQ")),
"Year Quarter Name",FORMAT([Date],"YYYY")&" Q"&FORMAT([Date],"Q"),
"Start of Quarter",DATE( YEAR([Date]), (QUARTER([Date])*3)-2, 1),
"End of Quarter",EOMONTH(DATE( YEAR([Date]), QUARTER([Date])*3, 1),0),
"Week of Year",WEEKNUM([Date]),
"Start of Week", [Date]-WEEKDAY([Date])+1,
"End of Week",[Date]+7-WEEKDAY([Date]),
"FY","FY-" & RIGHT(CONVERT(if(_startOfFiscalYear=1,YEAR([Date]),YEAR([Date])+ QUOTIENT(MONTH([Date])+ (13-_startOfFiscalYear),13)),STRING),2),
"Fiscal Year", if(_startOfFiscalYear=1,YEAR([Date]),YEAR([Date])+ QUOTIENT(MONTH([Date])+ (13-_startOfFiscalYear),13)),
"Fiscal Quarter",QUARTER( DATE( YEAR([Date]),MOD( MONTH([Date])+ (13-_startOfFiscalYear) -1 ,12) +1,1) ),
"Fiscal Month",MOD( MONTH([Date])+ (13-_startOfFiscalYear) -1 ,12) +1,
"Day Offset",DATEDIFF(_today,[Date],DAY),
"Month Offset",DATEDIFF(_today,[Date],MONTH),
"Quarter Offset",DATEDIFF(_today,[Date],QUARTER),
"Year Offset",DATEDIFF(_today,[Date],YEAR)
)
https://radacad.com/all-in-one-script-to-create-calendar-table-or-date-dimension-using-dax-in-power-bi