<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Default values for field parameter with language support? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Default-values-for-field-parameter-with-language-support/m-p/3733774#M145524</link>
    <description>&lt;P&gt;The error you're encountering, "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value," indicates that one or more expressions in your DAX code are returning multiple values where a single value is expected. This typically happens when you're trying to return a table or multiple values in a context where a single value is required, such as a measure or a variable.&lt;/P&gt;&lt;P&gt;In your case, the issue seems to be related to the fact that you're trying to return multiple rows of values within the SWITCH function, which expects a single scalar value for each case.&lt;/P&gt;&lt;P&gt;To resolve this issue, you need to restructure your DAX code so that it returns a single value for each case in the SWITCH function. One approach could be to return a single concatenated string that represents all the fields for a given language. Here's how you can adjust your code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_p_location_resolution =&lt;BR /&gt;VAR SelectedLanguage = SELECTEDVALUE('languages'[ISO abbreviation], "en")&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;SelectedLanguage,&lt;BR /&gt;"en", CONCATENATEX({"region", "country", "city", "terminal"}, [Value], ", "),&lt;BR /&gt;"sv", CONCATENATEX({"region", "land", "stad", "terminal"}, [Value], ", "),&lt;BR /&gt;"se", CONCATENATEX({"región", "país", "ciudad", "terminal"}, [Value], ", "),&lt;BR /&gt;// default to english&lt;BR /&gt;CONCATENATEX({"region", "country", "city", "terminal"}, [Value], ", ")&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this code:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;CONCATENATEX is used to concatenate the values of each field into a single string.&lt;/LI&gt;&lt;LI&gt;The {} syntax is used to create an array of field names for each language.&lt;/LI&gt;&lt;LI&gt;[Value] represents the value associated with each field.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This way, your DAX expression returns a single string for each language, which can be used as the default definition for your field parameter. Make sure to adjust [Value] with the appropriate expression that retrieves the values you want to concatenate for each field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Feb 2024 14:22:57 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2024-02-29T14:22:57Z</dc:date>
    <item>
      <title>Default values for field parameter with language support?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Default-values-for-field-parameter-with-language-support/m-p/3732945#M145478</link>
      <description>&lt;P&gt;I've got a field parameter to which I've added language support using the method describere here:&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/power-bi/guidance/data-translation-synchronize-field" target="_blank"&gt;Synchronize multiple field parameters - Power BI | Microsoft Learn&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_p_location_resolution = {
    //english
    ("region", NAMEOF('dim terminal'[region]), 0, 1),
    ("country", NAMEOF('dim terminal'[country]), 1, 1),
    ("city", NAMEOF('dim terminal'[city]), 2, 1),
    ("terminal", NAMEOF('dim terminal'[terminal]), 3, 1),
    //swedish
    ("region", NAMEOF('dim terminal'[region]), 0, 2),
    ("land", NAMEOF('dim terminal'[country]), 1, 2),
    ("stad", NAMEOF('dim terminal'[city]), 2, 2),
    ("terminal", NAMEOF('dim terminal'[terminal]), 3, 2),
    //spanish
    ("región", NAMEOF('dim terminal'[region]), 0, 3),
    ("país", NAMEOF('dim terminal'[country]), 1, 3),
    ("ciudad", NAMEOF('dim terminal'[city]), 2, 3),
    ("terminal", NAMEOF('dim terminal'[terminal]), 3, 3)
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;A problem with this is that if I add a language to my model but forget to update all field parameters there is no fallback. I use this field parameter in a slicer and If I filter for a language that is not supported by the field parameter the slicer becomes empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is if it is possible to modify this in order to add a default definition?&lt;/P&gt;&lt;P&gt;I tried letting ChatGPT be creative and it came up with this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_p_location_resolution = 
VAR SelectedLanguage = SELECTEDVALUE('languages'[ISO abbreviation], "en")
RETURN
    SWITCH(
        SelectedLanguage,
        "en",
            {
                ("region", NAMEOF('dim terminal'[region]), 0, 1),
                ("country", NAMEOF('dim terminal'[country]), 1, 1),
                ("city", NAMEOF('dim terminal'[city]), 2, 1),
                ("terminal", NAMEOF('dim terminal'[terminal]), 3, 1)
            },
        "sv",
            {
                ("region", NAMEOF('dim terminal'[region]), 0, 2),
                ("land", NAMEOF('dim terminal'[country]), 1, 2),
                ("stad", NAMEOF('dim terminal'[city]), 2, 2),
                ("terminal", NAMEOF('dim terminal'[terminal]), 3, 2)
            },
        "se",
            {
                ("región", NAMEOF('dim terminal'[region]), 0, 3),
                ("país", NAMEOF('dim terminal'[country]), 1, 3),
                ("ciudad", NAMEOF('dim terminal'[city]), 2, 3),
                ("terminal", NAMEOF('dim terminal'[terminal]), 3, 3)
            },
        // default to english
        {
            ("region", NAMEOF('dim terminal'[region]), 0, 1),
            ("country", NAMEOF('dim terminal'[country]), 1, 1),
            ("city", NAMEOF('dim terminal'[city]), 2, 1),
            ("terminal", NAMEOF('dim terminal'[terminal]), 3, 1)
        }
    )&lt;/LI-CODE&gt;&lt;P&gt;But this gives the error "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value".&lt;/P&gt;&lt;P&gt;Unfortunately I'm too new to Power BI and DAX to determine if it's just a tiny fixable error or if I'm not allowed to write DAX code like this in a field parameter. I'm guessing that the field parameter definition is not reloaded when changing the language filter so it isn't possible to do something like this but hey, I got to ask.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 08:40:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Default-values-for-field-parameter-with-language-support/m-p/3732945#M145478</guid>
      <dc:creator>martinriddar</dc:creator>
      <dc:date>2024-02-29T08:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Default values for field parameter with language support?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Default-values-for-field-parameter-with-language-support/m-p/3733774#M145524</link>
      <description>&lt;P&gt;The error you're encountering, "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value," indicates that one or more expressions in your DAX code are returning multiple values where a single value is expected. This typically happens when you're trying to return a table or multiple values in a context where a single value is required, such as a measure or a variable.&lt;/P&gt;&lt;P&gt;In your case, the issue seems to be related to the fact that you're trying to return multiple rows of values within the SWITCH function, which expects a single scalar value for each case.&lt;/P&gt;&lt;P&gt;To resolve this issue, you need to restructure your DAX code so that it returns a single value for each case in the SWITCH function. One approach could be to return a single concatenated string that represents all the fields for a given language. Here's how you can adjust your code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_p_location_resolution =&lt;BR /&gt;VAR SelectedLanguage = SELECTEDVALUE('languages'[ISO abbreviation], "en")&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;SelectedLanguage,&lt;BR /&gt;"en", CONCATENATEX({"region", "country", "city", "terminal"}, [Value], ", "),&lt;BR /&gt;"sv", CONCATENATEX({"region", "land", "stad", "terminal"}, [Value], ", "),&lt;BR /&gt;"se", CONCATENATEX({"región", "país", "ciudad", "terminal"}, [Value], ", "),&lt;BR /&gt;// default to english&lt;BR /&gt;CONCATENATEX({"region", "country", "city", "terminal"}, [Value], ", ")&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this code:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;CONCATENATEX is used to concatenate the values of each field into a single string.&lt;/LI&gt;&lt;LI&gt;The {} syntax is used to create an array of field names for each language.&lt;/LI&gt;&lt;LI&gt;[Value] represents the value associated with each field.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This way, your DAX expression returns a single string for each language, which can be used as the default definition for your field parameter. Make sure to adjust [Value] with the appropriate expression that retrieves the values you want to concatenate for each field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 14:22:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Default-values-for-field-parameter-with-language-support/m-p/3733774#M145524</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-02-29T14:22:57Z</dc:date>
    </item>
  </channel>
</rss>

