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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AlexGallet01
Helper IV
Helper IV

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")

1 ACCEPTED SOLUTION

@AlexGallet01

 

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. 

 

Tablescreenshot.jpg

 

 

 

 

 

 

 

 

 

 

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

View solution in original post

6 REPLIES 6
Dave1
Helper I
Helper I

Is 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])?

I can't use Max(Date[Anne]) because my objectid it's when i choose a year i want the result change to

Hi @AlexGallet01,

Have you resolved your issue? If you have, please mark the right/helpful reply as answer. More people will benefit from here. If you haven't, please feel free to ask.

Thanks,
Angelia

@AlexGallet01

 

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. 

 

Tablescreenshot.jpg

 

 

 

 

 

 

 

 

 

 

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

ccakjcrx
Resolver I
Resolver I

@AlexGallet01

 

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.

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.