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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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