Forum Discussion

NewbieJono's avatar
NewbieJono
Icon for Post Partisan rankPost Partisan
4 years ago
Solved

IF and AND

Hello i am trying to put some code in to check

 

if MAX date from date table = Today(), 

AND Group = "Mail"

 

Then

 

"Data Available"

 

Else

 

Data Not Available

 

any ideas?

  • Hi,

     

    there's some information missing (e.g. where is the Group-Column and how is the table connected to the date table?) but assuming there's a fact table with a Date which is linked to the Date column in your Date table and a Column Group which can have the value "Mail" this should do the trick. You can add it to a card for example.

    VAR isAvailable =
       CALCULATE(
           MAX(dateTable[Date]),
           yourOtherTable[Group] = "Mail"
       ) = TODAY()
    
    RETURN
       IF(isAvailable, "Data Available", "Data Not Available")
        

     

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi NewbieJono 

    Try

    if(MAX('table'[date] = Today() && 'table'[Group] = "Mail","Data Available","Data Not Available")
    • NewbieJono's avatar
      NewbieJono
      Icon for Post Partisan rankPost Partisan

      on this  after the && it will not let me select a table here, only measures

       

      if(MAX('table'[date] = Today() && 'table'[Group] = "Mail","Data Available","Data Not Available")
  • lukiz84's avatar
    lukiz84
    Icon for Memorable Member rankMemorable Member

    Hi,

     

    there's some information missing (e.g. where is the Group-Column and how is the table connected to the date table?) but assuming there's a fact table with a Date which is linked to the Date column in your Date table and a Column Group which can have the value "Mail" this should do the trick. You can add it to a card for example.

    VAR isAvailable =
       CALCULATE(
           MAX(dateTable[Date]),
           yourOtherTable[Group] = "Mail"
       ) = TODAY()
    
    RETURN
       IF(isAvailable, "Data Available", "Data Not Available")
        

     

    • NewbieJono's avatar
      NewbieJono
      Icon for Post Partisan rankPost Partisan

      This don't seem to work, the data is all in one table

       

      Mail isAvailable = 
      
      VAR isAvailable =
         CALCULATE(
             MAX('FACT - TEST'[Date]),
             'FACT - TEST'[Grouping] = "Mail Opening"
         ) = TODAY()
      
      RETURN
      
         IF(isAvailable, "Data Available", "Data Not Available")
      • lukiz84's avatar
        lukiz84
        Icon for Memorable Member rankMemorable Member

        Do you have any more infos? What does the measure return?