<?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: Conversion of SQL query into DAX expression in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2905692#M94792</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created a sample pbix file(&lt;STRONG&gt;&lt;SPAN&gt;see attachment&lt;/SPAN&gt;&lt;/STRONG&gt;) for you, please check whether that is what you want.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Create a&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;measure&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;as below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = 
VAR _tab =
    SUMMARIZE (
        FILTER (
            'shipingdetails',
            shipingdetails[BillingmonthKey] = shipingdetails[previousmonth]
                &amp;amp;&amp;amp; NOT ( shipingdetails[soldby] IN { "20", "30", "40" } )
        ),
        'shipingdetails'[matnbr],
        'shipingdetails'[shipplant],
        "@invqty", SUM ( 'shipingdetails'[invc_qty] ),
        "@salesamt", SUM ( 'shipingdetails'[sales_less_credits_amt] )
    )
VAR _invqty =
    SUMX ( _tab, [@invqty] )
VAR _salesamt =
    SUMX ( _tab, [@salesamt] )
RETURN
    IF (
        (
            NOT ( ISBLANK ( _invqty ) )
                &amp;amp;&amp;amp; _invqty &amp;lt;= 3
        )
            || (
                NOT ( ISBLANK ( _salesamt ) )
                    &amp;amp;&amp;amp; _salesamt &amp;lt;= 10
            ),
        1,
        0
    )&lt;/LI-CODE&gt;
&lt;P&gt;2.&amp;nbsp;&lt;SPAN&gt;Create a table visual and apply the visual-level filter with the condition(&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Flag is 1&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 07:52:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-11-15T07:52:45Z</dc:date>
    <item>
      <title>Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2904038#M94679</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Hope you all are doing good.&lt;/P&gt;&lt;P&gt;As i am a newbie to this DAX Expresssion i have a hard time converting the below SQL Query into DAX.&lt;/P&gt;&lt;P&gt;Any answer would be much appreciated.&lt;/P&gt;&lt;P&gt;I have 3 steps to do so how do we solve the below problem from your solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;SQL Query :&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1. SELECT Mat From MaterialProducts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. For the Mat identified in Step1&lt;BR /&gt;SELECT MATNBR, shipplant , sum(invcqty), sum(saleslesscreditsamt) from shipingdetails&lt;BR /&gt;WHERE BillingmonthKey = previousmonth&lt;BR /&gt;AND soldby NOT IN ('20', '30', '40')&lt;BR /&gt;GROUP BY matnbr, shipplant&lt;BR /&gt;HAVING sum(invcqty) &amp;lt;= 3.000 or&lt;BR /&gt;sum(Saleslesscreditsamt ) &amp;lt;= 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step-3: For the items identified in Step2&lt;BR /&gt;SELECT Mat, Number, qty From MaterialProducts&lt;BR /&gt;WHERE Mat = MATNBR(From Step2)&lt;BR /&gt;and Number = shipplant (From Step2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to convert but it is not working so thought of posting a question for the conversion.&lt;/P&gt;&lt;P&gt;Shipingdetails = EVALUATE&lt;BR /&gt;SELECTCOLUMNS (&lt;BR /&gt;'shipingdetails',&lt;BR /&gt;"MATNBR", "shipplant" , sum(shipingdetails[invcqty]), sum(shipingdetails[saleslesscreditsamt])", 'shipingdetails'[MATNBR], [shipplant] , [sum(shipingdetails[invcqty])], [sum(shipingdetails[saleslesscreditsamt])]&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Thanks in Advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 14:47:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2904038#M94679</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-16T14:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2904284#M94694</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EVALUATE
FILTER (
    ADDCOLUMNS (
        CALCULATETABLE (
            SUMMARIZE ( shipingdetails, shipingdetails[MATNBR], MATNBR[shipplant] ),
            shipingdetails[BillingmonthKey] = shipingdetails[previousmonth],
            NOT shipingdetails[soldby] IN { "20", "30", "40" }
        ),
        "@InvoiceQty", CALCULATE ( SUM ( shipingdetails[invc_qty] ) ),
        "@CreditAmt", CALCULATE ( SUM ( shipingdetails[sales_less_credits_amt] ) )
    ),
    [@InvoiceQty] &amp;lt;= 3
        || [@CreditAmt] &amp;lt;= 10
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2022 17:11:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2904284#M94694</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2022-11-14T17:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2905692#M94792</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created a sample pbix file(&lt;STRONG&gt;&lt;SPAN&gt;see attachment&lt;/SPAN&gt;&lt;/STRONG&gt;) for you, please check whether that is what you want.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Create a&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;measure&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;as below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = 
VAR _tab =
    SUMMARIZE (
        FILTER (
            'shipingdetails',
            shipingdetails[BillingmonthKey] = shipingdetails[previousmonth]
                &amp;amp;&amp;amp; NOT ( shipingdetails[soldby] IN { "20", "30", "40" } )
        ),
        'shipingdetails'[matnbr],
        'shipingdetails'[shipplant],
        "@invqty", SUM ( 'shipingdetails'[invc_qty] ),
        "@salesamt", SUM ( 'shipingdetails'[sales_less_credits_amt] )
    )
VAR _invqty =
    SUMX ( _tab, [@invqty] )
VAR _salesamt =
    SUMX ( _tab, [@salesamt] )
RETURN
    IF (
        (
            NOT ( ISBLANK ( _invqty ) )
                &amp;amp;&amp;amp; _invqty &amp;lt;= 3
        )
            || (
                NOT ( ISBLANK ( _salesamt ) )
                    &amp;amp;&amp;amp; _salesamt &amp;lt;= 10
            ),
        1,
        0
    )&lt;/LI-CODE&gt;
&lt;P&gt;2.&amp;nbsp;&lt;SPAN&gt;Create a table visual and apply the visual-level filter with the condition(&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Flag is 1&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 07:52:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2905692#M94792</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-15T07:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2907885#M94928</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236628" data-lia-user-login="AntrikshSharma" class="lia-mention lia-mention-user"&gt;AntrikshSharma&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your response in that ,&lt;/P&gt;&lt;P&gt;Sorry! I have 3 steps to do so how do we solve the below problem from your solution then.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. SELECT Mat From MaterialProducts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. For the Mat identified in Step1 &lt;STRONG&gt;(For which the solution is provided)&lt;/STRONG&gt;&lt;BR /&gt;SELECT MATNBR, shipplant , sum(invcqty), sum(saleslesscreditsamt) from shipingdetails&lt;BR /&gt;WHERE BillingmonthKey = previousmonth&lt;BR /&gt;AND soldby NOT IN ('20', '30', '40')&lt;BR /&gt;GROUP BY matnbr, shipplant&lt;BR /&gt;HAVING sum(invcqty) &amp;lt;= 3.000 or&lt;BR /&gt;sum(Saleslesscreditsamt ) &amp;lt;= 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step-3: For the items identified in Step2&lt;BR /&gt;SELECT Mat, Number, qty From MaterialProducts&lt;BR /&gt;WHERE Mat = MATNBR(From Step2)&lt;BR /&gt;and Number = shipplant (From Step2)&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 14:48:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2907885#M94928</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-16T14:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2908004#M94934</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;In order to give you a suitable solution, could you&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in the table &lt;STRONG&gt;'MaterialProducts'&lt;/STRONG&gt; and&lt;STRONG&gt; 'shipingdetails'&lt;/STRONG&gt; (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples? By the way, is there any relationship created between these two tables? If yes, please also provide the related info(cardinality, cross filter direction etc.).&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 01:12:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2908004#M94934</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-16T01:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2909893#M95080</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MaterialProducts Table&lt;/P&gt;&lt;P&gt;SQL Query : SELECT * From MaterialProducts&lt;/P&gt;&lt;P&gt;DateCreated&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mat&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MatID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Qty&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Number&lt;BR /&gt;2022-11-16 10:45:23.657 000000000010163475&amp;nbsp; 10163475&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 031&lt;BR /&gt;2022-11-16 10:45:23.657 000000000010041325&amp;nbsp; 10041325&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 071&lt;BR /&gt;2022-11-16 10:45:23.657 000000000010198072&amp;nbsp; 10198072&amp;nbsp; &amp;nbsp; &amp;nbsp; 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 081&lt;BR /&gt;2022-11-16 10:45:23.657 000000000010178854&amp;nbsp; 10178854&amp;nbsp; &amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 011&lt;/P&gt;&lt;P&gt;Step 1 : Expected SQL Query :- SELECT Mat From MaterialProducts&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Shipingdetails Table&lt;/P&gt;&lt;P&gt;SQL Query : SELECT * From Shipingdetails&lt;/P&gt;&lt;P&gt;MATNBR&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;shipplant&amp;nbsp; &amp;nbsp; invcqty&amp;nbsp; &amp;nbsp;saleslesscreditsamt BillingmonthKey soldby&lt;BR /&gt;000000000010189497&amp;nbsp; &amp;nbsp; &amp;nbsp;018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8.07&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20221101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;BR /&gt;000000000010231301&amp;nbsp; &amp;nbsp; &amp;nbsp;023&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13.96&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20221101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;BR /&gt;000000000010158010&amp;nbsp; &amp;nbsp; &amp;nbsp;029&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4.34&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20221101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;BR /&gt;000000000010051031&amp;nbsp; &amp;nbsp; &amp;nbsp;018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6.23&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20221101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;Step 2 :&lt;BR /&gt;Expected SQL Query :-&lt;BR /&gt;SELECT MATNBR, shipplant , sum(invcqty), sum(saleslesscreditsamt) from Shipingdetails&lt;BR /&gt;WHERE BillingmonthKey = previousmonth&lt;BR /&gt;AND soldby NOT IN ('20', '30', '40')&lt;BR /&gt;GROUP BY matnbr, shipplant&lt;BR /&gt;HAVING sum(invcqty) &amp;lt;= 3.000 or&lt;BR /&gt;sum(Saleslesscreditsamt ) &amp;lt;= 10&lt;/P&gt;&lt;P&gt;Assume that the Result of this query is stored in a temp table named "TempShipingdetails"&lt;/P&gt;&lt;P&gt;Note - previousmonth should be the month calculated by todays date and it should be in format YYYYMMDD , For Eg :20221001&lt;BR /&gt;For the previous month i am using the DAX logic&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var previousmonth = DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step 3:&lt;BR /&gt;Expected SQL Query :&lt;BR /&gt;SELECT Mat, Number, Qty From MaterialProducts M&lt;BR /&gt;WHERE M.Mat = MATNBR(From TempShipingdetails)&lt;BR /&gt;and M.Number = shipplant (From TempShipingdetails)&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 15:05:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2909893#M95080</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-16T15:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2911692#M95159</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can create a measure as below to get it base on the formula which provide by&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236628" data-lia-user-login="AntrikshSharma" class="lia-mention lia-mention-user"&gt;AntrikshSharma&lt;/a&gt;&amp;nbsp;, and create a table visual with filter conditon&lt;STRONG&gt;&lt;EM&gt; Flag is 1&lt;/EM&gt; &lt;/STRONG&gt;(see &lt;STRONG&gt;the screenshot&lt;/STRONG&gt; below). Please find the details in &lt;STRONG&gt;the attachment&lt;/STRONG&gt;.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = 
VAR _selmat =
    SELECTEDVALUE ( 'MaterialProducts'[Mat] )
VAR _selnum =
    SELECTEDVALUE ( 'MaterialProducts'[Number] )
VAR _prmonth =
    EOMONTH ( TODAY (), -1 )
VAR _previousmonth =
    VALUE ( YEAR ( _prmonth ) &amp;amp; FORMAT ( _prmonth, "mm" ) &amp;amp; "01" ) //just for testing
VAR _tab =
    FILTER (
        ADDCOLUMNS (
            CALCULATETABLE (
                SUMMARIZE (
                    FILTER (
                        shipingdetails,
                        'Shipingdetails'[MATNBR] = _selmat
                            &amp;amp;&amp;amp; 'Shipingdetails'[shipplant] = _selnum
                    ),
                    shipingdetails[MATNBR],
                    'Shipingdetails'[shipplant]
                ),
                shipingdetails[BillingmonthKey] = _previousmonth,
                NOT shipingdetails[soldby] IN { "20", "30", "40" }
            ),
            "@InvoiceQty", CALCULATE ( SUM ( Shipingdetails[invcqty] ) ),
            "@CreditAmt", CALCULATE ( SUM ( Shipingdetails[saleslesscreditsamt] ) )
        ),
        [@InvoiceQty] &amp;lt;= 3
            || [@CreditAmt] &amp;lt;= 10
    )
RETURN
    IF (
        _selmat = MAXX ( _tab, [MATNBR] )
            &amp;amp;&amp;amp; _selnum = MAXX ( _tab, [shipplant] ),
        1,
        0
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 07:04:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2911692#M95159</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-17T07:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of SQL query into DAX expression</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2915837#M95488</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am still facing one issue (Issue is i am not able to retreive the correct value of qty or the sum value of qty from MaterialProducts in step 3 because it is not filtering based on the flag if i create a visual(To be precise it is not filtering based on the Step 3) ) , Say for instance i want to remove this flag concept and for Step 3, I just need to return the Qty or the Sum of the Qty based on Step3 (i.e the filter (WHERE Mat = MATNBR(From Step2)&lt;BR /&gt;and Number = shipplant (From Step2)) instead of flag 1 or 0 in if condition. Also just had a small question why this MAXX function is applied , it will just return the largest MAT_NBR or largest Ship_Plant right. Sorry! I am going back and forth with this question, i am a newbie so was trying to understand and make this work. Thank You for understanding and really appreciate that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Step-3: For the items identified in Step2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT Mat, Number, qty From MaterialProducts&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WHERE Mat = MATNBR(From Step2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and Number = shipplant (From Step2)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 22:22:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conversion-of-SQL-query-into-DAX-expression/m-p/2915837#M95488</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-18T22:22:47Z</dc:date>
    </item>
  </channel>
</rss>

