Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

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

  • Anonymous's avatar
    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's avatar
      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. 

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

     

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

     

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