Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AndySmith
Helper III
Helper III

Tabular Editor Script - Time Intelligence - Financial YTD

 

Hi - I have the below very useful code taken from Havens consulting. Was wondering if anyone had used this but with a financial YTD instead of calendar YTD? Our FY ends in June. 

/*
 * Generate time intelligence measures based
 *
 * Modified by: Reid Havens, https://havensconsulting.net 
 * Original Author(s): Benoit Fedit, https://datakuity.com 
 * Original Author(s): Bernat Agulló, www.esbrina-ba.com/blog 
 *
 */

// Creates popup promots to select the calendar table, and date column, to then dynamically update the scripts below
var CalendarTable = SelectTable(label: "Select your calendar table");
if(CalendarTable == null) return;

var CalendarTableDateColumn = SelectColumn(CalendarTable.Columns, label: "Select the date key column");
if(CalendarTableDateColumn == null) return;
string CalendarTableName = CalendarTable.Name;
string CalendarTableDateColumnName = CalendarTableDateColumn.Name;

// For each selected measure create YTY, PY, PY YTD, YOY, YOY% measures
foreach(var m in Selected.Measures) {
    
    // YTD
    m.Table.AddMeasure(
    m.Name + " YTD",                                       // Name
    "\r\n" +                                               // Carriage Return
    "CALCULATE(" + 
    "\r\n" +                                               // Carriage Return
    "   " + m.DaxObjectName + "," +
    "\r\n" +                                               // Carriage Return
    "   DATESYTD( '" + CalendarTableName + "'[" + CalendarTableDateColumnName + "] )" +
    "\r\n" +                                               // Carriage Return
    ")",
    ".Time Intelligence\\" +  m.Name     // Display Folder
    );
    

Hi 

1 REPLY 1
Anonymous
Not applicable

Hi  @AndySmith ,

 

This is the related document, you can view this content:

blog.enterprisedna.co

DAX Formulas for Fiscal Year, Fiscal Quarter and M... - Microsoft Fabric Community

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.