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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Uzi2019
Super User
Super User

Previous Row record in matrix - dynamic

Hi Experts,

I have one matrix which will look like below, In that I want to compute Previous Day Amount. But When I drilldown to only Month so it would show Previous Month in the same matrix and DAX.

Brand

Order ID

Start Date

End Date

Order Date

Amount

AAA

1234567

24-Apr-23

01-May-23

24-Apr-23

100

AAA

1234567

24-Apr-23

01-May-23

25-Apr-23

200

AAA

1234567

24-Apr-23

01-May-23

26-Apr-23

140

AAA

1234567

24-Apr-23

01-May-23

27-Apr-23

200

AAA

1234567

24-Apr-23

01-May-23

28-Apr-23

100

AAA

1234567

24-Apr-23

01-May-23

29-Apr-23

120

AAA

1234567

24-Apr-23

01-May-23

30-Apr-23

210

AAA

1234567

24-Apr-23

01-May-23

01-May-23

100

 

Expected Output:  (When we drill up to till Month so In May column the sum of April should get displayed.)

Uzi2019_0-1683267156968.png

 

Uzi2019_0-1683267399075.png

 

 

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Uzi2019 

 

You can try the following methods.

Previous Sum = 
Var _Sum=CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),MONTH([Order Date])=SELECTEDVALUE('Table'[Order Date].[MonthNo])-1))+0
Return
IF(SUM('Table'[Amount])=BLANK(),BLANK(),_Sum)
Output = IF(HASONEVALUE('Table'[Order Date].[Day]),SUM('Table'[Amount]),[Previous Sum])

vzhangti_0-1683525309628.png

vzhangti_2-1683525339920.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @Uzi2019 

 

You can try the following methods.

Previous Sum = 
Var _Sum=CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),MONTH([Order Date])=SELECTEDVALUE('Table'[Order Date].[MonthNo])-1))+0
Return
IF(SUM('Table'[Amount])=BLANK(),BLANK(),_Sum)
Output = IF(HASONEVALUE('Table'[Order Date].[Day]),SUM('Table'[Amount]),[Previous Sum])

vzhangti_0-1683525309628.png

vzhangti_2-1683525339920.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

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!

December 2024

A Year in Review - December 2024

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