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
henryvu93
Helper I
Helper I

DAX formula for referencing previous cells in the row

Hi guys,

 

I created a matrix (screenshot below is a sample):

PivotTable.PNG

Basically "1" & "0" here are for determining the status of the customer: If customer bought something in a month, I marked them as Active ("1"). For this purpose, I used the function:

if([MonthlyPrice]  > 0 , 1, 0)

 

Now, I want to create a new measure: if they are "Active" over the last 3 months (current month, previous month & the month before previous month), I mark them as "Returning" customers. I would like the table to calculate this new status every month for e.g. if we are looking at Dec 2015, the status be based on Oct-15, Nov-15 & Dec-15 and so on. However, I don't know if we can reference the cutomer's "Active" status for previous months. I just wonder if we can use DAX to do something like that?

 

Any help/insight will be really appreciated! Thank you!

 

Henry

1 ACCEPTED SOLUTION
henryvu93
Helper I
Helper I

I think I found the solution for this: I created a date column based on [Month] & [Year]; then I calculate the moving sum of "Active" status over the last 3 months for each row using the DATESINPERIOD() function. The matrix was just an end result. Thank you for very useful discussion on:

 

https://community.powerbi.com/t5/Desktop/Moving-Average/m-p/43041#M16519

 

 

View solution in original post

1 REPLY 1
henryvu93
Helper I
Helper I

I think I found the solution for this: I created a date column based on [Month] & [Year]; then I calculate the moving sum of "Active" status over the last 3 months for each row using the DATESINPERIOD() function. The matrix was just an end result. Thank you for very useful discussion on:

 

https://community.powerbi.com/t5/Desktop/Moving-Average/m-p/43041#M16519

 

 

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.