Forum Discussion
vsorensen
1 year agoFrequent Visitor
Using measure to compare two columns in a matrix
As the title suggests, I have two columns in a matrix that I need to compare. Both are date columns and I am trying to display the difference between the two. The issue I'm having, is when I try to d...
- 1 year ago
vsorensen Try:
Start Variance = SWITCH( TRUE(), [Start] = BLANK(), BLANK(), [Start] = [BL Start], 0, NETWORKDAYS([Start], [BL Start]) )
vsorensen
1 year agoFrequent Visitor
Greg_Deckler I had to put MIN() around my column references but other than that it worked, thank you! Can you explain why this works? I had tried the code below before in one of my many attempts to figure it out but with no luck.
SWITCH(
TRUE(),
MIN([Start]) = MIN([BL Start]), 0,
ISBLANK(MIN(p6_data[BL Start])), BLANK(),
NETWORKDAYS([Start], [BL Start])
)
Greg_Deckler
Community Champion
1 year agovsorensen Oh, fair, I guess it is a measure and all. Basically, SWITCH TRUE is a nifty way of writing nested IF statements more cleanly. So, with SWITCH TRUE, you list out logical tests which are evaluated in order. If a logical test is met, then the corresponding value is returned so think of it like this:
SWITCH( TRUE(),
<Logical Test 1>, <Result if Logical Test 1 is true>,
<Logical Test 2>, <Result if Logical Test 2 is true>,
<Result if all other tests evaluate to false>
- vsorensen1 year agoFrequent Visitor
Greg_Deckler right, I am familiar with the SWITCH TRUE formula, my question is if you had any insight as to why the SWITCH formula in my last message did not work while the one you provided did. From what I can tell, the two are effectively the same.