Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Calculated column for getting ABS Value

Hello,

 

Can anyone help me with the below scenario. Not able to get get the proper absolute values when doing a difference of values between two columns.

 

Column A

Column B

Column C

Column D 

Coumn E = Column B+Column C+Column D 

Column F = Column E - Column A

ABS Column F = ABS(Column E - Column A)

 

Sample data structure:

DATEETRECNAMERVRBDiff
31/09/2019NACPMASTER1137942.4300
31/09/2019NACPRE LLC-5538.8800
31/09/2019NACPRE LLC27503662.900
31/09/2019NACPSDL649975.7100
31/09/2019NASCLLC0632500000
31/09/2019BHSCRE LLC-25164.3900

 

If i create a measure the values are coming as expected but not with a calculated column. I cant use a measure because i have to use calculated column in a matrix which has the show data points as a table option, which only appears if i use a calculated column.

So please help me how should i write a calculated column to get the correct abs values.

 

I tried to even do something like IF <0 THEN *-1 ELSE *1 on column F but it is not giving the proper results, my data is very granular i.e many transactions for a customer and i am not able to figure out how the results are computed at calculated column level to tweek the code

 

Appreciate if someone can help me with this

 

Thanks!

 

 

3 Replies

  • Hi Anonymous !

    Please share some sample data so we can work with the example. Also please share te DAX formula you are using for measure. You might use use the same DAX to create new column.

     

    Regards,

    Hasham

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

    Can you please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.

    How to Get Your Question Answered Quickly  

    Regards,

    Xiaoxin Sheng

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

    Any update on your requirement? 

    BTW, if you want to achieve a custom summary in calculated columns, you may need to manually add filters to calculate and summarize records with partial row and column category fields.

    Clever Hierarchy Handling in DAX - SQLBI

    Regards,

    Xiaoxin Sheng