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

New Column from previous row and another column

Hey!

 

I am trying to make a new Column (NewColumn) or Measure, where it uses the state of the row before, for example:

 

Time      Duration(s)      State               NewColumn (ActualState)     Index

2014             150          Operational             Operational                    1'

2014             150          Operational             Operational                    2

2014             150          Operational             Operational                    3

2014             150          Operational             Operational                    4

2014              1            Indeterminate           Operational                   5

2014             150          Operational             Operational                    6

2014             150          Operational             Operational                    7

 

 

For example I want and IF Function, if the duration of tim is less then 4 seconds then use the State of Previous Index, so I want a new Column called ActualState as can be seen. I have tried many different DAX functions but cant make anybody work. 

Here are some thoughts: (havent made anything work)

 

ActualState =
var CurrentIndex = Utilizations[Index2] -1
VAR UtilizationsState2 = Utilizations[State] of the index "CurrentIndex"??
return


IF(Utilizations[Duration_s]>4,Utilizations[State],
IF(Utilizations[Duration_s]<=4, UtilizationsState2 ))

 

ActualState =

var CurrentIndex= MAX(Utilizations[Index2])

var UtilizationsState2 =Utilizations[State] in CurrentIndex-1

return

 

IF(Utilizations[Duration_s]>4,Utilizations[State],

IF(Utilizations[Duration_s]<=4, UtilizationsState2))

 

ActualState2 =

FILTER(Utilizations,EARLIER((Utilizations[Index2]-1)))

 

Helpful for help,

 

Kind regards

1 ACCEPTED SOLUTION
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this as a "New Column"

 

NewState = 
VAR _PrevVal = LOOKUPVALUE(Test65PrevRow[State],Test61AbNormalDiff[Index],Test65PrevRow[Index]-1)
RETURN IF(Test65PrevRow[Duration]<4,_PrevVal,Test65PrevRow[State])

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




View solution in original post

2 REPLIES 2
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this as a "New Column"

 

NewState = 
VAR _PrevVal = LOOKUPVALUE(Test65PrevRow[State],Test61AbNormalDiff[Index],Test65PrevRow[Index]-1)
RETURN IF(Test65PrevRow[Duration]<4,_PrevVal,Test65PrevRow[State])

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

@PattemManohar Thanks!!

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.