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
Anonymous
Not applicable

LOOKUPVALUE with measure

I want to use a similar function than LOOKUPVALUE that works with measures.

My objective is to display the LAST year's value

 

I have a Dataset like this:

Romain_L_0-1624605050307.pngRomain_L_1-1624605064770.png

There is a relationship between the Two 'Date' collumns.

 

I use measures to compile data for a specific region (and other parameters in my full dataset): 

Sales A Measure = CALCULATE(SUM('Table'[Sales]), 'Table'[Region] == "A")
 
I want to have a 'Sales A Last year' value:
Romain_L_4-1624605722912.png

I want to use the 'Date match + 1' as a reference to get the last year's value.


 

How can i do That ?

 

7 REPLIES 7
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

Could you provide a specific sample ? This can help us better deal with the problem .

 

Best Regards

Community Support Team _ Ailsa Tao

 

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

Anonymous
Not applicable

I've edited the main post, tell me if that is enough. I don't think i can link the exemple pbix ...

m3tr01d
Continued Contributor
Continued Contributor

@Anonymous Can you give us an example where the result is wrong because of leap year and tell us what result you would like to have.

amitchandak
Super User
Super User

@Anonymous , Try measures like

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

 

or for YTD

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

Anonymous
Not applicable

The problem is DATEADD and SAMEPERIODLASTYEAR are incorrect for me as they do not work with leap years AND my measure is a bit more complex than a SUM

Why will the SAMEPERIODLASTYEAR() not work?  In what situation will it fail?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

to @Ashish_Mathur

 

So when i tried:

Year behind Sales = CALCULATE([SalesMeasure]),SAMEPERIODLASTYEAR('Date'[Date]))

I don't get the same day of the week.

Romain_L_0-1623825234800.png

this makes next year look like this :

Romain_L_1-1623825320984.png

And it's shifted from what i want, i want the same day of the week; tuesday to tuesday.

 

The server i'm pulling my data from gives me the 'Next year corresponding day', that is correct for me, hence why i want to just match the collumn

 

 

 

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.