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
JPSCHAFFER
Frequent Visitor

DAX or MCode formula help: copy cell in row until change in row

Hi, 

I need a DAX (or M) formula to replicate the data in column [TEXT3]. Let's call this table 'Table1'. 

I want to copy the text in column [TEXT1] until there is a change triggered by "MAKE" in [TEXT2].

 

Maybe usage of EARLIER or SWITCH in this case?   

 

TEXT1TEXT2TEXT3
12ASMAKE12AS
34ABBUY12AS
12CBUY12AS
12DBUY12AS
99MAKE99
B24BUY99
B33BUY99
A12BUY99
102MAKE102
C1BUY102
C2BUY102
C3BUY102
33MAKE33
3ABUY33
5ABUY33
1 ACCEPTED SOLUTION

Hi @JPSCHAFFER ,

 

I've added the index column , then use below calculated column:

 
Column = VAR a = 'Table'[Index]
RETURN
 CALCULATE (MAX ( 'Table'[TEXT1] ),FILTER (ALL ( 'Table' ),'Table'[Index]= CALCULATE (MAX ( 'Table'[Index] ),FILTER ( ALL ( 'Table' ), 'Table'[Index] <= a && 'Table'[TEXT2] = "MAKE" ))))

03.PNG

Best regards,

Dina Ye

Community Support Team _ Dina Ye
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

7 REPLIES 7
JPSCHAFFER
Frequent Visitor

Or, I can always add an Index Column as well to force the order of column [TEXT1]

Hi @JPSCHAFFER ,

 

I've added the index column , then use below calculated column:

 
Column = VAR a = 'Table'[Index]
RETURN
 CALCULATE (MAX ( 'Table'[TEXT1] ),FILTER (ALL ( 'Table' ),'Table'[Index]= CALCULATE (MAX ( 'Table'[Index] ),FILTER ( ALL ( 'Table' ), 'Table'[Index] <= a && 'Table'[TEXT2] = "MAKE" ))))

03.PNG

Best regards,

Dina Ye

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Now I'm having an issue when implementing. 

Error : "The function MAX takes an argument that evaluates to numbers or dates and cannot work with values of type String."

 

= VAR a =BOMs[Index]
RETURN

CALCULATE (MAX ( BOMs[PART NO] ),
FILTER (ALL (BOMs ),
BOMs[Index]= CALCULATE (MAX ( BOMs[Index] ),
FILTER ( ALL ( BOMs ), BOMs[Index] <= a && BOMs[MAKE OR BUY] = "MAKE" ))))

I'm in PowerPivot so I wonder if I need to use MAXX instead of MAX (?)

Thanks so much!

AiolosZhao
Memorable Member
Memorable Member

Hi @JPSCHAFFER ,

 

I think for this function, the sort of your table is very important, could you please tell me the column that you sort the table, and what if user change the sort in the table?

 

Aiolos Zhao





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

Proud to be a Super User!




Column [TEXT1] would be the ascending sort I guess.

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.