Forum Discussion

VGoncalves's avatar
VGoncalves
Regular Visitor
4 years ago
Solved

TotalYTD not working

Hello,

 

i have this measure:

HIRINGS_L1Y =
CALCULATE(SUM(BD_COLAB[HIRING]), DATESINPERIOD(DIM_DATES[Date], MAX(DIM_DATES[Date]), -13, MONTH))
 
This measure will give me, for example, for feb'22 i will have the sum of all the employee hirings from feb'21 and feb'22, it will give me, for example 200 hirings. But in jan'22 i will have 190 hirings
 
And after this, i want the YTD of hirings for each month  (i know it sounds weird, but its for a very specific reason), for example, for this example my YTD would be 390 YTD hirings 
 
But i did this measure:
HIRINGS_L1Y_YTD = TOTALYDT ([HIRINGS_L1Y], DIM_DATES[Date]) 
 
and is returning the samething i have on the previous measure, its not giving me the sum of the YTD. For feb'22 its giving me 200 hirings and not 390.
 
What am i doing wrong?
 
thank you
  • VGoncalves , try like

     

    HIRINGS_L1Y =
    var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
    var _min = eomonth(_max,-1*MONTH(_max))+1
    return
    CALCULATE(Sumx(Values(DIM_DATES[Month Year]),
    CALCULATE(SUM(BD_COLAB[HIRING]), DATESINPERIOD(DIM_DATES[Date], MAX(DIM_DATES[Date]), -13, MONTH))),DATESBETWEEN('Date'[Date],_min,_max))

3 Replies

  • VGoncalves , try like

     

    HIRINGS_L1Y =
    var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
    var _min = eomonth(_max,-1*MONTH(_max))+1
    return
    CALCULATE(Sumx(Values(DIM_DATES[Month Year]),
    CALCULATE(SUM(BD_COLAB[HIRING]), DATESINPERIOD(DIM_DATES[Date], MAX(DIM_DATES[Date]), -13, MONTH))),DATESBETWEEN('Date'[Date],_min,_max))

    • VGoncalves's avatar
      VGoncalves
      Regular Visitor

      @amitchandak  i run again the measure, and still doesnt work, but the numbers arent that off. For jan'22 i have 378 hirings and for feb'22 i have 399 hirings, should give me a YTD of 777 hirings, but using your measure will give me 798 hirings.. its not that off, but isnt right

    • VGoncalves's avatar
      VGoncalves
      Regular Visitor

      amitchandak i was able to solve the difference of numbers, i did a separate measure for the ytd. thank you so much for your help!!