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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Hussein_charif
Helper II
Helper II

Versus previous

Hi, i wanted to check if there is a similar function to the previous() visual calculation function but with measures?

Also, i have this visual calc:
Diff
IF(
ISINSCOPE([itemno]) &&
NOT ISINSCOPE([year]) &&
NOT ISINSCOPE([monthname]) &&
NOT ISINSCOPE([day]),
BLANK(),
IF(
ISBLANK(PREVIOUS([Total AVG Cost])),
0,
IF(
ISBLANK([Total AVG Cost]),
0,
[Total AVG Cost] - PREVIOUS([Total AVG Cost])
)
)
)

In the photo, you can see i have multiple itemNo. For the first row, for example itemNo 10002, the difference there is doing total avg cost of year 2022 of itemNo 10002 - total avg cost of year 2024 of itemNo 1, which is wrong. What can i do in this case to prevent the previous function from taking the total avg cost of different years?
WhatsApp Image 2024-10-21 at 6.42.41 PM.jpeg

1 ACCEPTED SOLUTION

Yes, by using PREVIOUS() and indicating which direction you want to look.

View solution in original post

5 REPLIES 5
v-tianyich-msft
Community Support
Community Support

Hi @Hussein_charif ,

 

Please provide sample data as well as your expected results.

 

Best regards,
Community Support Team_ Scott Chang

lbendlin
Super User
Super User

There are no row numbers in DAX - you need to provide your own by specifying how you want the data sorted. Once you have that you can use the Window functions like OFFSET.

okay well, is there a way to solve the problem within visual calculations?

Yes, by using PREVIOUS() and indicating which direction you want to look.

used PREVIOUS([Total AVG Cost],1,-1) and it worked, thank you

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.