The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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
Solved! Go to Solution.
Hi @sarath_chandra ,
Please try below steps:
1. below is my test table
Table:
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
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.
Hi @sarath_chandra ,
Please try below steps:
1. below is my test table
Table:
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
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.