Forum Discussion

refkabeji's avatar
refkabeji
New Member
3 years ago

Multiple columns cannot be converted to a scalar value

Hi guys

I would ask you about how can I compare values from table to measure .

END_DATE_ESP =

var tmp =
    SELECTCOLUMNS ( Table_param_version, "SelectColumn1", [version] )
VAR _str =
    CONCATENATEX ( tmp, [SelectColumn1] )
var tmp2 =
    SELECTCOLUMNS ( Year_param, "SelectColumn2", [Année] )
VAR _str2 =
    CONCATENATEX ( tmp2, [SelectColumn2] )
return YEAR(datevalue(SWITCH(_str, "Actuali",concatenate(concatenate(concatenate(CONCATENATE([Day_selected1],"/"),[Mois_selected1]),"/"),_str2+1),"Provisoire",concatenate(concatenate(concatenate(CONCATENATE([Day_selected1],"/"),[Mois_selected1]),"/"),_str2))))
 
after I would compare the end_date_esp to other column
Colonne = if(ESP_FAIT_INTRPL_POLCR[END_DATE]< [END_DATE_ESP] , ESP_FAIT_INTRPL_POLCR[NOM_AGENC] , BLANK())
 
=> it return null 
 
I appreciate your help! thanks .
 

5 Replies

  • Please provide your sample file and not screenshots. At least the data (input) and the expected ouput.

    Otherwise after reading what you provided I am assuming the following :

     

    The DAX code you provided calculates an `END_DATE_ESP` and compares it with another column to produce a value for `Colonne`.

    END_DATE_ESP Calculation
    - First, it extracts the `version` column from the `Table_param_version` and the `Année` column from `Year_param` into two separate temporary variables.
    - It concatenates the values extracted into two strings `_str` and `_str2`.
    - Then it forms a date based on some conditions and extracts the year from that date.

    Colonne Calculation
    - It compares the `END_DATE` from the `ESP_FAIT_INTRPL_POLCR` table with the previously calculated `END_DATE_ESP`. If `END_DATE` is less, it returns the `NOM_AGENC` value, otherwise it returns blank.

    If the `Colonne` column is returning null:

    Issue with END_DATE_ESP: The `END_DATE_ESP` might not be getting calculated properly, which can happen if any of the referenced columns like `Day_selected1`, `Mois_selected1`..., have null values or if the `SWITCH` statement doesn't match any value and defaults to returning blank.

    Ensure that `ESP_FAIT_INTRPL_POLCR` has values in `END_DATE` and `NOM_AGENC`.

     The comparison might be failing due to a data type mismatch or due to some conditions not being met.

    Try to :

    1. Check if `END_DATE_ESP` returns a valid value on its own without using it in the next calculation.
    2. Ensure the `ESP_FAIT_INTRPL_POLCR` table's `END_DATE` has the correct data type and it has valid values.
    3. Check the data types of `END_DATE_ESP` and `ESP_FAIT_INTRPL_POLCR[END_DATE]` to ensure they are comparable.
    4. Try the `Colonne` calculation without the `if` condition to see if it can pull the `NOM_AGENC` value correctly.

     

  • pls try this

    --- if(ESP_FAIT_INTRPL_POLCR[END_DATE]< DATEVALUE([END_DATE_ESP]) , ESP_FAIT_INTRPL_POLCR[NOM_AGENC] , BLANK())

  • hello ahmed

    datevalue(SWITCH(_str, "Actuali",concatenate(concatenate(concatenate(CONCATENATE([Day_selected1],"/"),[Mois_selected1]),"/"),_str2+1),"Provisoire",concatenate(concatenate(concatenate(CONCATENATE([Day_selected1],"/"),[Mois_selected1]),"/"),_str2)))

    yes It contains datevalue but It does'nt word.

    may be because I compare column with measure ?

    • Ahmedx's avatar
      Ahmedx
      Icon for Super User rankSuper User

      Can you please share your demo input and expected output!

      • refkabeji's avatar
        refkabeji
        New Member

        Hello guys

         

        My input is : 

         

         

        I would compare column in my fact table with this mesure :

        how can I compare Mesure with column

         

         

        thank you