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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.