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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

IF ELSE in DAX Measure using only Dimensions causes error

Hi Team

 

I am working on a report connected to a Power BI dataset. 

 

I am building a Table visual,I am using one fact from Fact Table and there are other dimension values coming from different dimension tables.

 

There are 2 dates coming from 2 different dimesnions (in the table visual). I am trying to compare if Dim1.Date < Dim2.Date then give 1 else 0.

 

I have written 2 measures to get the 2 dates 

 

DateFrom Dim1 = 

CALCULATE(MAXX('FactTable',MAX('Dim1'[Date])),'FactTable')
 
DateFrom Dim2 = CALCULATE(MAXX('FactTable',MAX('Dim2'[Date])),'FactTable')
 
When I use these 2 measures in the visual they return the corresponding dates for each row correctly.
 
I need to compare these 2 measures (these 2 dates).
 
I write a measure 
 
DatesCompare = IF(DateFrom Dim1 < DateFrom Dim2,1,0)
 
It works perfect with only TRUE condition but when I include the ELSE condition in the measure i.e 0 and use it in the visual it keeps on loading and causes error.
 
Can anyone help me with the DAX for it and why including the ELSE condition causes error?
 
3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , if Dim1 and dim2 are joined these two should work

 

MAXX(allselected('Dim1'),'Dim1'[Date])

 

MAXX(allselected('Dim2'),'Dim2'[Date])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hello @Anonymous 
I've created the same measure and tried but it works fine.
Can you share some data and visuals where you're using the above measures?

Anonymous
Not applicable

Hi @Anonymous 

I cannot share data since its company specific and also is a Live connection to a Power BI dataset.

 

Along with the 2 dates from 2 dimension tables and these 3 measures there are other dimensions getting used in the Table visual. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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