Forum Discussion

eHorizons's avatar
eHorizons
Frequent Visitor
2 years ago

Creating Calculated Column Based on Measure

Hi Everyone,

I'm trying to create a calculated column based on either a measure or a column in another table. I have tried both methods below and in both cases the column only calculates off the first condition and I get this result every time: 'T Tests'[Timepoint 1] - 'T Tests'[Timepoint 2])

 

Method 1: Creating conditional calculated column using a calculated measure in the same table

dif =
If([Group] = "Timepoint 1 vs 2", 'T Tests'[Timepoint 1] - 'T Tests'[Timepoint 2],
    IF([Group]="Timepoint 2 vs 3", 'T Tests'[Timepoint 2] - 'T Tests'[Timepoint 3], 'T Tests'[First] - 'T Tests'[Most Recent]))
 
Method 2: Creating conditional calculated column using a column in another table
dif =
SWITCH(TRUE(),
        FIRSTNONBLANK('Group'[Group],1)="Timepoint 1 vs 2",
       'T Tests'[Timepoint 1] - 'T Tests'[Timepoint 2],
        FIRSTNONBLANK('Group'[Group],1)="Timepoint 2 vs 3",
        'T Tests'[Timepoint 2] - 'T Tests'[Timepoint 3],
        'T Tests'[First] - 'T Tests'[Most Recent]
        )
 
Any ideas who I can get the desired result? Thanks!

1 Reply