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

A calculated column returning a specific value from an "internal table"

Hello,
can someone please help me to ride a DAX formula in order to determine the value of an additional column

[Value of Test] is the additional column that needs to be calculated
The dataset contain multiple articles [ID], and each article has several "transactions lines" ordered from oldest to newest
The value of this calculated column needs to be value in the column "Previous Value" of the first transaction after the transactions "START" as in the example below

 

Bjorn_C_2-1639428411383.png

 

Thx for the support and help 

Bjorn 

 

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Bjorn_C , You can get previous value like

 

New column =
var _max = maxx(filter(Table, [ID] =earlier([ID]) && [Date] <earlier([Date])) , [Date])
return
maxx(filter(Table, [ID] =earlier([ID]) && [Date] =_max ) , [value])

 

 

But I am not clear on who you got those previous values

View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @Bjorn_C ,

Here are the steps you can follow:

1. In Power query, Add Column – Index Column From 1.

vyangliumsft_0-1639619202116.png

2. Create calculated column.

 

Value of test =
var _STARTIndex=CALCULATE(SUM('Table'[Index]),FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[rcode]="START"))
return
CALCULATE(SUM('Table'[Previous Value]),FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Index]=_STARTIndex+1))

 

3. Result:

vyangliumsft_1-1639619202118.png

 

Best Regards,

Liu Yang

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

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @Bjorn_C ,

Here are the steps you can follow:

1. In Power query, Add Column – Index Column From 1.

vyangliumsft_0-1639619202116.png

2. Create calculated column.

 

Value of test =
var _STARTIndex=CALCULATE(SUM('Table'[Index]),FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[rcode]="START"))
return
CALCULATE(SUM('Table'[Previous Value]),FILTER(ALL('Table'),'Table'[ID]=EARLIER('Table'[ID])&&'Table'[Index]=_STARTIndex+1))

 

3. Result:

vyangliumsft_1-1639619202118.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@Bjorn_C , You can get previous value like

 

New column =
var _max = maxx(filter(Table, [ID] =earlier([ID]) && [Date] <earlier([Date])) , [Date])
return
maxx(filter(Table, [ID] =earlier([ID]) && [Date] =_max ) , [value])

 

 

But I am not clear on who you got those previous values

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.