Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

If condition

Hi

I am trying to make a condition: If column month>=month(now);sum(X);sum(y)

The problem is that when I make the condition I can only put measures and functions. I don't have the option to reference columns why? 

 

 

6 Replies

  • Mariusz's avatar
    Mariusz
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

     

    Basically Measurs dont work with row context so you need to use MAX or MIN, something like below.

    If MAX(column month )> = MONTH( TODAY() );sum(X);sum(y)


    Please read the article below for more info.

    https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

     

    Regards,
    Mariusz

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Mariusz 

       

      I try 

      Valor total = if(MAX(Doc_Factura[Mês])>=MONTH(TODAY());[Facturação Bruta];[SumValorPub])
       
      but I keep receiving the error:
       

      "Dax comparison operations do not support comparing values of type text with values of type integer."

       

      Doc_Factura[Mês],month(today()), Facturação bruta; sumValorPub are integers and decimals  so I don't understand the error.

      I try to make a new column with funtion value but the error was the same

      IF(VALUE(MONTH(Doc_Factura[data_doc_df]))<=VALUE(MONTH(TODAY()));[Facturação Bruta];[SumValorPub])
      • Cmcmahan's avatar
        Cmcmahan
        Icon for Resident Rockstar rankResident Rockstar

        Check your tables.  Make sure that PBI recognizes that Doc_Factura[Mes] is an integer value and not a string.

        Otherwise, using VALUE should have worked to force a type change.