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
wer1231
Regular Visitor

DAX get previous values from another DAX

Hi all, 

 

I am new to DAX . So I am trying to build the `DAX Value 2` column. Below is what I am expecting for `DAX Value 2` column. 

For the 'category' C, I want it to be the value of Category B on the measure instead of a running total. 

 

Notes: both the DAX Value 1 and DAX Value 2 will be a Measure instead of from a Table

 

Screenshot 2021-01-27 at 10.04.21 AM.png

 

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi,  @wer1231 

You can try the following steps.

 

1 Create a Calculated column with Measure DAX Value1

ColumnFromValue1 = [DAX_Value1]

 

2 Create a Measure

Accumulate =

VAR res =

    CALCULATE (

        SUMX ( 'Table', 'Table'[ColumnFromValue1] ),

        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] <= MAX ( 'Table'[Index] ) )

    )

VAR r1 =

    LOOKUPVALUE ( 'Table'[ColumnFromValue1], 'Table'[Category], "A" )

VAR r2 =

    LOOKUPVALUE ( 'Table'[ColumnFromValue1], 'Table'[Category], "B" )

VAR r3 = r1 + r2

RETURN

IF ( SELECTEDVALUE ( 'Table'[Category] ) = "C", r3, res )

 

The result looks like this:

v-cazheng-msft_0-1611892590690.png

 

Best Regards,

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If not, please consider providing a sample removing sensitive data.

View solution in original post

6 REPLIES 6
v-cazheng-msft
Community Support
Community Support

Hi,  @wer1231 

You can try the following steps.

 

1 Create a Calculated column with Measure DAX Value1

ColumnFromValue1 = [DAX_Value1]

 

2 Create a Measure

Accumulate =

VAR res =

    CALCULATE (

        SUMX ( 'Table', 'Table'[ColumnFromValue1] ),

        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] <= MAX ( 'Table'[Index] ) )

    )

VAR r1 =

    LOOKUPVALUE ( 'Table'[ColumnFromValue1], 'Table'[Category], "A" )

VAR r2 =

    LOOKUPVALUE ( 'Table'[ColumnFromValue1], 'Table'[Category], "B" )

VAR r3 = r1 + r2

RETURN

IF ( SELECTEDVALUE ( 'Table'[Category] ) = "C", r3, res )

 

The result looks like this:

v-cazheng-msft_0-1611892590690.png

 

Best Regards,

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. If not, please consider providing a sample removing sensitive data.

Ashish_Mathur
Super User
Super User

Hi,

What result are you expecting?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Updated my post. Let me know if it is still unclear....

Sorry for the confusion. The `DAX Value 2` column is what I am expecting to achieve. Will modify my question right now...

 

 

StefanoGrimaldi
Resident Rockstar
Resident Rockstar

first try on the table tools theres a quick measure pane, you can find there a pre defined running total function just specify the parameters field for it and should get you on the road. 





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




But I am looking to get the previous row value for one specific row, if that make sense. PS: have modified my question above. 

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!

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.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.