Forum Discussion

suebayes's avatar
suebayes
Resolver I
6 years ago
Solved

Tabular Editor FYTD

I am trying to create a Fiscal YTD measure in Tabular Editor but am getting stuck on the code to include a text value at the end of the YTD, I've tried to create a variable but the endYear has to be in quotes.  I've underlined the part I'm stuck on. 

// Creates a TOTALYTD measure for every selected measure. 
var dateColumn = "'Date'[Date]"; 
var endYear = "31/05"; 
foreach(var m in Selected.Measures) 
{ m.Table.AddMeasure( m.Name + " YTD", // Name "TOTALYTD(" + m.DaxObjectName + ", " + dateColumn + ", " + "'endYear'"+ ")", 
m.DisplayFolder // Display Folder ); } 

 

  • suebayes's avatar
    suebayes
    6 years ago

    I think I have worked it out

    // Creates a TOTALYTD measure for every selected measure.
    foreach(var m in Selected.Measures) {
    m.Table.AddMeasure(
    m.Name + " YTD", // Name
    "TOTALYTD(" + m.DaxObjectName + ", 'Date'[Date], " + "\"31/05\")", // DAX expression
    m.DisplayFolder // Display Folder
    );
    }

5 Replies