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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
sarath_chandra
Helper III
Helper III

dax help

HI , in my dataset ,im having setup columns S1,S2,S3,S4,...upto S12.and date column - first day of every month (1/1/2018 to 12/1/2022) and field values . I need previous row difference of each rows .but first row of each setup should be null or zero (it should not take difference of previous set ups) for example s2 should not take the field values of s1. so that particular row should be zero or null. and in difference i have to use ABS dax function to avoid negative sign in output column.

kindly see the data set.please help me out. vry thankfull for your help

sarath_chandra_0-1671114957255.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sarath_chandra ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1672050360353.png

2. create a measure with below dax formula

Measure =
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR cur_val =
    SELECTEDVALUE ( 'Table'[Field Value] )
VAR cur_st =
    SELECTEDVALUE ( 'Table'[Setup] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), 'Table'[Setup] = cur_st && 'Table'[Date] < cur_date )
VAR pre_date =
    MAXX ( tmp, [Date] )
VAR pre_val =
    CALCULATE (
        MAX ( 'Table'[Field Value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = pre_date && 'Table'[Setup] = cur_st )
    )
RETURN
    IF ( DAY ( cur_date ) = 1, 0, ABS ( cur_val - pre_val ) )

3. add a table visual with fields and measure

vbinbinyumsft_1-1672050526613.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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
Anonymous
Not applicable

Hi @sarath_chandra ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1672050360353.png

2. create a measure with below dax formula

Measure =
VAR cur_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR cur_val =
    SELECTEDVALUE ( 'Table'[Field Value] )
VAR cur_st =
    SELECTEDVALUE ( 'Table'[Setup] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), 'Table'[Setup] = cur_st && 'Table'[Date] < cur_date )
VAR pre_date =
    MAXX ( tmp, [Date] )
VAR pre_val =
    CALCULATE (
        MAX ( 'Table'[Field Value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = pre_date && 'Table'[Setup] = cur_st )
    )
RETURN
    IF ( DAY ( cur_date ) = 1, 0, ABS ( cur_val - pre_val ) )

3. add a table visual with fields and measure

vbinbinyumsft_1-1672050526613.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

serpiva64
Solution Sage
Solution Sage

Hi,

Starting from this

serpiva64_0-1671116338789.png

You obtain your result

serpiva64_1-1671116425482.png

applaying the steps you find in the attached file

If this post is useful to help you to solve your issue consider giving the post a thumbs up serpiva64_2-1671116497046.png and accepting it as a solution !

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors