Forum Discussion

MG4's avatar
MG4
Regular Visitor
8 years ago
Solved

calculated field on same table and field

Hi all,

 

On "X" table I have two (relevant) fields: "weeks" and "volume".

I want to display 3 columns: the volume on current week , the volume on the previous week and the difference between these two weeks (Delta).

I have tried to do so but I don't know how to calculate the delta between two columns that actually belong to the same field.

 

Thanks in advanced!

  • Anonymous's avatar
    Anonymous
    8 years ago

    MG4,


    Create the following columns in your table. If the DAX don't help, please share dummy data of your table and post expected result.

    pre = CALCULATE(FIRSTNONBLANK(X[Volume],1),FILTER(X,X[Weeks]=EARLIER(X[Weeks])-1))
    delta = IF(ISBLANK(X[pre]),BLANK(), X[Volume]-X[pre])



    Regards,
    Lydia

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    MG4,


    Create the following columns in your table. If the DAX don't help, please share dummy data of your table and post expected result.

    pre = CALCULATE(FIRSTNONBLANK(X[Volume],1),FILTER(X,X[Weeks]=EARLIER(X[Weeks])-1))
    delta = IF(ISBLANK(X[pre]),BLANK(), X[Volume]-X[pre])



    Regards,
    Lydia