<?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: Is it possible to store DAX operators as a string and recall them in an expression? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351983#M125879</link>
    <description>&lt;P&gt;I can't download the file, can you provide a table example in the reply? And how you want to use the measure? (What visual, and where)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2023 22:13:26 GMT</pubDate>
    <dc:creator>AnthonyGenovese</dc:creator>
    <dc:date>2023-07-26T22:13:26Z</dc:date>
    <item>
      <title>Is it possible to store DAX operators as a string and recall them in an expression?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351734#M125866</link>
      <description>&lt;P&gt;We track metric actual values against metric target values and color code the actual values based on a pre-determined polarity. Some actual values are better if they are higher than the target and some actual values are better if they are lower than the target.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to store the DAX operators for each metric in a table and retrieve that operator in an IF statement when comparing values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example use something like this:&lt;/P&gt;&lt;P&gt;color_code = if ( metrics[ actual ] &amp;amp; polarity[ operator ] &amp;amp; metrics[ target ] , "red" , "green" )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To return this:&lt;/P&gt;&lt;P&gt;color_code = if ( 80 &amp;gt;= 75 , "red" , "green" )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this result:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;color_code =&lt;/FONT&gt; 80&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 18:24:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351734#M125866</guid>
      <dc:creator>djallarii</dc:creator>
      <dc:date>2023-07-26T18:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to store DAX operators as a string and recall them in an expression?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351941#M125876</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="553998" data-lia-user-login="djallarii" class="lia-mention lia-mention-user"&gt;djallarii&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it won't work like that, but you can use your setup to get the output you are looking for. You would do something like this&lt;BR /&gt;var greaterthan =&amp;nbsp;&lt;SPAN&gt;if ( metrics[ actual ]&amp;gt;= metrics[ target ] , "red" , "green" )&lt;BR /&gt;&lt;/SPAN&gt;var lessthan =&amp;nbsp;&lt;SPAN&gt;if ( metrics[ actual ]&amp;lt;= metrics[ target ] , "red" , "green" )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Var color_code = if (polarity[ operator ] ="&amp;gt;=",&amp;nbsp;greaterthan, lessthan)&lt;BR /&gt;&lt;/SPAN&gt;return color_code&lt;BR /&gt;If this post was helpful, please kudos or accept the answer as a solution.&lt;BR /&gt;~ Anthony Genovese&lt;BR /&gt;Need more PBI help? PM me for affordable, dedicated training or consultant recomendations!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 21:22:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351941#M125876</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-26T21:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to store DAX operators as a string and recall them in an expression?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351971#M125878</link>
      <description>&lt;P&gt;Awesome, I understand what you're doing here but I'm curious if we can make it a bit more dynamic than hardcoding the colors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example file:&lt;/P&gt;&lt;P&gt;&lt;A href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2F1drv.ms%2Fu%2Fs!AoXwZT-xo7jRgfUbkOYcOp_ixAwzwA%3Fe%3DQDfTqa&amp;amp;data=05%7C01%7CDavid.Allar%40sluhn.org%7C42e3fbd642c54ff4c0f008db8e22e97c%7Cef4fd2f84c9645ab9b157831920f55cf%7C0%7C0%7C638260052833935615%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=7SpO5BIXlHAYrM4w0aJaIYRHZz8lj3k%2BmpNIUxJOWJA%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;Color Format.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you apply your logic to achieve similar results using the polarity_ID to return the color formats from the color_format_true and color_format_false fields?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm thinking a SWITCH function using the polarity_ID could work where each expression and related operator is returned but I get duplicate results per metric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like:&lt;BR /&gt;If polarity ID = 1 then evaluate SelectedActual &amp;gt; SelectedTarget,&amp;nbsp;ColorTrue, ColorFalse&lt;BR /&gt;If polarity ID = 2 then evaluate SelectedActual &amp;lt; SelectedTarget, ColorTrue, ColorFalse&lt;BR /&gt;If polarity ID = 3 then evaluate SelectedActual &amp;lt;= SelectedTarget, ColorTrue, ColorFalse&lt;BR /&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 22:03:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351971#M125878</guid>
      <dc:creator>djallarii</dc:creator>
      <dc:date>2023-07-26T22:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to store DAX operators as a string and recall them in an expression?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351983#M125879</link>
      <description>&lt;P&gt;I can't download the file, can you provide a table example in the reply? And how you want to use the measure? (What visual, and where)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 22:13:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3351983#M125879</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-07-26T22:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to store DAX operators as a string and recall them in an expression?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3352041#M125882</link>
      <description>&lt;P&gt;I uploaded the file to Google Drive and my personal OneDrive to try again:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Google Drive Link -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1CbPcYgLduKUY47oUueflzIwEMTvlhS4r%2Fview%3Fusp%3Ddrive_link&amp;amp;data=05%7C01%7CDavid.Allar%40sluhn.org%7C52093090dbbe46e18c2f08db8e2ebe50%7Cef4fd2f84c9645ab9b157831920f55cf%7C0%7C0%7C638260103677712090%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=NQLw7rIisPVfP5K4akSAKGVGzC7xTfKtNb%2FdEzoeAvQ%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;https://drive.google.com/file/d/1CbPcYgLduKUY47oUueflzIwEMTvlhS4r/view?usp=drive_link&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OneDrive Link -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2F1drv.ms%2Fu%2Fs!AoXwZT-xo7jRgfUcCYqWcjoD6Divcw%3Fe%3DffxJBd&amp;amp;data=05%7C01%7CDavid.Allar%40sluhn.org%7C52093090dbbe46e18c2f08db8e2ebe50%7Cef4fd2f84c9645ab9b157831920f55cf%7C0%7C0%7C638260103677712090%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=jC9AYSVu%2BsxypnOWA2DLr9BF2Y4wSE%2FdgggcWbFpnXI%3D&amp;amp;reserved=0" target="_bl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ffd100&lt;/TD&gt;&lt;TD&gt;#80c342&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;=&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;#a05da5&lt;/TD&gt;&lt;TD&gt;Grey&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The return statement in this measure should be dynamic if possible which is where the idea for a SWITCH statement came in.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 23:30:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3352041#M125882</guid>
      <dc:creator>djallarii</dc:creator>
      <dc:date>2023-07-26T23:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to store DAX operators as a string and recall them in an expression?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3353041#M125928</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="422509" data-lia-user-login="AnthonyGenovese" class="lia-mention lia-mention-user"&gt;AnthonyGenovese&lt;/a&gt;&amp;nbsp;I wanted to let you to know I was able to get the intended results using your original post and accepted it as the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am still curious if you can figure out a solution to my follow up example, however. If you have a chance to take a look, I would appreciate it!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 10:55:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-it-possible-to-store-DAX-operators-as-a-string-and-recall/m-p/3353041#M125928</guid>
      <dc:creator>djallarii</dc:creator>
      <dc:date>2023-07-27T10:55:12Z</dc:date>
    </item>
  </channel>
</rss>

