Forum Discussion
don't understand
Hello,
I don't understand why 2 measures with the same function hidden different result.
Measure 1:
Measure A-3 = var yeartoday = YEAR(TODAY())
var yearstart = yeartoday - 4
var theDatesTable = DATESBETWEEN('Date'[Date]; DATE(yearstart;7;1); DATE(yeartoday;6;30))
return
CALCULATE(CALCULATE(SUM('OPPFinal'[E.Amount]);theDatesTable;'OPPFinal'[E.StageName]="Close gagnée")
Measure 2:
[Exercice choisi] = SelectedValue('Date'[Année])
Measure test A-3 = var yeartoday = [Exercice choisi]
var yearstart = yeartoday - 4
var theDatesTable = DATESBETWEEN('Date'[Date]; DATE(yearstart;7;1); DATE(yeartoday;6;30))
return
CALCULATE(CALCULATE(SUM('OPPFinal'[E.Amount]);theDatesTable;'OPPFinal'[E.StageName]="Close gagnée")
Hey!
I don't have access to your data, so I'm have to make some presumptions about your data model.
I hope the following screenshot shows the difference between how SELECTEDVALUE and YEAR(TODAY()) calculates the date. It appears to be looking at the day rather than the year value.
The columns that have names beginning with Msr are measures. Here are the measures I used for each of those columns:
MsrYearToday = YEAR(TODAY()) MsrYearToday - 4 = [MsrYearToday] - 4 MsrSelectedValue - 4 = SELECTEDVALUE(Sheet1[ClmYearofDate]) - 4
Click HERE to access my .pbix file
6 Replies
- ccakjcrxResolver I
Hey!
Can you provide a link to your .pbix file?
The only difference I can see is how the yeartoday variable is defined. That said, I suppose there is a difference between how YEAR(TODAY()) and SELECTEDVALUE is calculating dates.
- AlexGallet01Helper IV
I can't do a link to my .pbix sorry. And yes but the result of Year(today()) AND [Exercice choisi] is 2017 (integer) so i don't undestand why i dont'have the same result.
- Dave1Advocate IIIs the value SelectedValue(date[Annee]) is equivalent to year(today())?
Measure 1 takes the year value dynamically from your today's date and it should be 2017.
Measure 2 takes the year value from your table. In stead of SelectedValue can you use Max(Date[Annee])?- AlexGallet01Helper IV
I can't use Max(Date[Anne]) because my objectid it's when i choose a year i want the result change to
- ccakjcrxResolver I
Hey!
I don't have access to your data, so I'm have to make some presumptions about your data model.
I hope the following screenshot shows the difference between how SELECTEDVALUE and YEAR(TODAY()) calculates the date. It appears to be looking at the day rather than the year value.
The columns that have names beginning with Msr are measures. Here are the measures I used for each of those columns:
MsrYearToday = YEAR(TODAY()) MsrYearToday - 4 = [MsrYearToday] - 4 MsrSelectedValue - 4 = SELECTEDVALUE(Sheet1[ClmYearofDate]) - 4
Click HERE to access my .pbix file