Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
vsorensen
Frequent 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 directly compare the two columns, the matrix is populated with every single row in my table. For example, this is the result I am looking for, where "Start" and "Baseline Start" are the columns I am pulling in from my data table, and "Start Variance" is a measure:

WBSStartBaseline Start   Start Variance
WBS13/1/2023   1/16/2023-31
     WBS23/1/20231/16/2023-31

          Work Package 2   

3/1/20231/16/2023-31

          Work Package 5   

6/3/20242/8/2024-80

          Work Package 6   

2/1/20245/3/202465

 

But when I try and create a start variance measure like this:

Start Variance = 
IF([Start] = [BL Start], 0, NETWORKDAYS([Start], [BL Start]))

 

Then I end up with a matrix that lists every single row in my data table, which is what I do not want:

WBSStartBaseline Start   Start Variance
WBS13/1/2023   1/16/2023-31
     WBS23/1/20231/16/2023-31

          Work Package 1   

  0

          Work Package 2   

3/1/20231/16/2023-31

          Work Package 3   

  0

          Work Package 4   

  0

          Work Package 5   

6/3/20242/8/2024-80

          Work Package 6   

2/1/20245/3/202465

 

So how do I create a measure that compares these two columns?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@vsorensen Try:

Start Variance = 
  SWITCH( TRUE(),
    [Start] = BLANK(), BLANK(),
    [Start] = [BL Start], 0, 
    NETWORKDAYS([Start], [BL Start])
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@vsorensen Try:

Start Variance = 
  SWITCH( TRUE(),
    [Start] = BLANK(), BLANK(),
    [Start] = [BL Start], 0, 
    NETWORKDAYS([Start], [BL Start])
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@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])
)
 

@vsorensen 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>

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@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.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.