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
Anonymous
Not applicable

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 @Anonymous ,

 

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
Anonymous
Not applicable

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

Hi @Anonymous ,

 

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.
Anonymous
Not applicable

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" ))))

Anonymous
Not applicable

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

Anonymous
Not applicable

Thanks so much!

Anonymous
Not applicable

Hi @Anonymous ,

 

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

Anonymous
Not applicable

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

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.