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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
refkabeji
New Member

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 5
AmiraBedh
Super User
Super User

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.

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
refkabeji
New Member

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 ?

Can you please share your demo input and expected output!

Hello guys

 

My input is : 

refkabeji_0-1693751627617.png

 

 

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

refkabeji_1-1693752043588.png

how can I compare Mesure with column

refkabeji_2-1693752134530.png

 

 

thank you  

Ahmedx
Super User
Super User

pls try this

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.