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
NQT1711
Regular Visitor

How to get previous values

Hi there, 

 

I have a table like that:

Market_WeekSum Quantity
2705
38272
48285
68705
78717
88726
109211
1240157
1343308
1547564
1649146

And i want to get previous values like:

Market_WeekSum QuantityPrevious Sum Quantity
2705 
38272705
482858272
687058285
787178705
887268717
1092118726
12401579211
134330840157
154756443308
164914647564

How can I handle this?

Thank you and I look forward to your support.

2 ACCEPTED SOLUTIONS
DataNinja777
Super User
Super User

Hi @NQT1711 

I am sure there are many ways to do this, but one way is to create a calculated column for the indexing by rankx, and then to create another calculated column bringing the previous row.  

DataNinja777_0-1713969678436.png

 

 

DataNinja777_1-1713969710455.png

Best regards,

View solution in original post

v-kongfanf-msft
Community Support
Community Support

Hi @NQT1711 ,

 

Creating calculated columns is indeed a good option, as @DataNinja777  provides.


However, if your data model is too large, it may increase the memory burden since the calculated columns will actually be added to the data model.

Perhaps create a measure is a good option, refer to the following formula:

MEASURE =
MAXX (
    FILTER ( ALL ( 'Table' ), 'Table'[Market_Week] < MAX ( 'Table'[Market_Week] ) ),
    [Sum Quantity]
)

vkongfanfmsft_0-1714034734820.png

 

Best Regards,
Adamk Kong

 

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

View solution in original post

4 REPLIES 4
v-kongfanf-msft
Community Support
Community Support

Hi @NQT1711 ,

 

Creating calculated columns is indeed a good option, as @DataNinja777  provides.


However, if your data model is too large, it may increase the memory burden since the calculated columns will actually be added to the data model.

Perhaps create a measure is a good option, refer to the following formula:

MEASURE =
MAXX (
    FILTER ( ALL ( 'Table' ), 'Table'[Market_Week] < MAX ( 'Table'[Market_Week] ) ),
    [Sum Quantity]
)

vkongfanfmsft_0-1714034734820.png

 

Best Regards,
Adamk Kong

 

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

DataNinja777
Super User
Super User

Hi @NQT1711 

I am sure there are many ways to do this, but one way is to create a calculated column for the indexing by rankx, and then to create another calculated column bringing the previous row.  

DataNinja777_0-1713969678436.png

 

 

DataNinja777_1-1713969710455.png

Best regards,

Kaviraj11
Responsive Resident
Responsive Resident

There's two way that you can do it now. 

1. Create a Measure

var _selecteddate= FIRSTDATE('Calendar'[week])-1

var PreviousDayTotal=CALCULATE(SUM(QUANTITTY),TREATAS({_selecteddate},'Calendar'[week]))

RETURN

IF(SUM(QUANTITTY)=BLANK(),BLANK(), SUM(QUANTITTY))

 

2. New features

You can calculate the previous value using new calculation as well which is the prefered solution now.

Visual calculations (preview) | Microsoft Power BI Blog | Microsoft Power BI

Kaviraj11,

 

I strongly disagree that visual calculations are the preferred solution.

 

They're still a preview feature. They are also specific to the visual only and cannot be reused anywhere else.

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.