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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.