<?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 Help with complex query in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-complex-query/m-p/3025038#M103108</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;I'm trying to creat a new Incidents column in a table based on some complex conditions.&lt;/P&gt;&lt;P&gt;I have 48 vars that calculate the count of department names occur in an affected Dept table but also filter based on the "event cataegory" in the issues table. so far this seems to all work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is I need to get each of these values into the new incidents column in the correct row based on Dept. Name but I can't figure out how.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some same code I have so far;&lt;/P&gt;&lt;P&gt;Incidents =&lt;BR /&gt;// the var below calculates the number incidents that affect ALL depts&lt;BR /&gt;var All_Tot = CALCULATE(COUNT('Impacted_Departments'[Impacted_Departments]),FILTER('Impacted_Departments','Impacted_Departments'[Impacted_Departments]="All"))&lt;/P&gt;&lt;P&gt;//the following var was intended as a place holder to be able to add a Dept. total with the All_Total&lt;BR /&gt;var Dept_Total = All_Total '&lt;/P&gt;&lt;P&gt;//the var belaow gets the # of impacted depts filtered for this particular dept. from an impacted deptments table as well as filtered //for the event_category "Cyber Incident" from an issues table&lt;BR /&gt;var PSPC= CALCULATE(COUNT('Impacted_Departments'[Impacted_Departments]),FILTER('Impacted_Departments','Impacted_Departments'[Impacted_Departments]="Public Services and Procurement Canada (PSPC)"),FILTER(Issues,Issues[Event_Category_12005]="Cyber Incident"))&lt;/P&gt;&lt;P&gt;//The below is another var calculated like the on above filtered for the same event_category but for a different dept&lt;BR /&gt;var TC= CALCULATE(COUNT('Impacted_Departments'[Impacted_Departments]),FILTER('Impacted_Departments','Impacted_Departments'[Impacted_Departments]="Transport Canada (TC)"),FILTER(Issues,Issues[Event_Category_12005]="Cyber Incident"))&lt;BR /&gt;RETURN&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can return the correct count for either of the 2 vars above but I need to be able to add the All_Total with the total for each dept the insert that number into the correct row of the Incidents column based on Dept name. Keep in mind that this needs to be done 48 times in total.&lt;/P&gt;&lt;P&gt;I've tried several conditional statements like switch and IF statements but it errors out on the syntax as I cannot figure out how to do it correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2023 08:02:12 GMT</pubDate>
    <dc:creator>BarryM</dc:creator>
    <dc:date>2023-01-17T08:02:12Z</dc:date>
    <item>
      <title>Help with complex query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-complex-query/m-p/3025038#M103108</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;I'm trying to creat a new Incidents column in a table based on some complex conditions.&lt;/P&gt;&lt;P&gt;I have 48 vars that calculate the count of department names occur in an affected Dept table but also filter based on the "event cataegory" in the issues table. so far this seems to all work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is I need to get each of these values into the new incidents column in the correct row based on Dept. Name but I can't figure out how.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some same code I have so far;&lt;/P&gt;&lt;P&gt;Incidents =&lt;BR /&gt;// the var below calculates the number incidents that affect ALL depts&lt;BR /&gt;var All_Tot = CALCULATE(COUNT('Impacted_Departments'[Impacted_Departments]),FILTER('Impacted_Departments','Impacted_Departments'[Impacted_Departments]="All"))&lt;/P&gt;&lt;P&gt;//the following var was intended as a place holder to be able to add a Dept. total with the All_Total&lt;BR /&gt;var Dept_Total = All_Total '&lt;/P&gt;&lt;P&gt;//the var belaow gets the # of impacted depts filtered for this particular dept. from an impacted deptments table as well as filtered //for the event_category "Cyber Incident" from an issues table&lt;BR /&gt;var PSPC= CALCULATE(COUNT('Impacted_Departments'[Impacted_Departments]),FILTER('Impacted_Departments','Impacted_Departments'[Impacted_Departments]="Public Services and Procurement Canada (PSPC)"),FILTER(Issues,Issues[Event_Category_12005]="Cyber Incident"))&lt;/P&gt;&lt;P&gt;//The below is another var calculated like the on above filtered for the same event_category but for a different dept&lt;BR /&gt;var TC= CALCULATE(COUNT('Impacted_Departments'[Impacted_Departments]),FILTER('Impacted_Departments','Impacted_Departments'[Impacted_Departments]="Transport Canada (TC)"),FILTER(Issues,Issues[Event_Category_12005]="Cyber Incident"))&lt;BR /&gt;RETURN&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can return the correct count for either of the 2 vars above but I need to be able to add the All_Total with the total for each dept the insert that number into the correct row of the Incidents column based on Dept name. Keep in mind that this needs to be done 48 times in total.&lt;/P&gt;&lt;P&gt;I've tried several conditional statements like switch and IF statements but it errors out on the syntax as I cannot figure out how to do it correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 08:02:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-complex-query/m-p/3025038#M103108</guid>
      <dc:creator>BarryM</dc:creator>
      <dc:date>2023-01-17T08:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with complex query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-complex-query/m-p/3025093#M103110</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="323739" data-lia-user-login="BarryM" class="lia-mention lia-mention-user"&gt;BarryM&lt;/a&gt;&amp;nbsp;Hi! Can you attach the pbix file or paste some sample data and the expected result? To better understand the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BBF&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 08:18:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-complex-query/m-p/3025093#M103110</guid>
      <dc:creator>BeaBF</dc:creator>
      <dc:date>2023-01-17T08:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help with complex query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-complex-query/m-p/3025742#M103164</link>
      <description>&lt;P&gt;I did include some test code in my post, but I have no way to insert the pbix file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 12:37:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-with-complex-query/m-p/3025742#M103164</guid>
      <dc:creator>BarryM</dc:creator>
      <dc:date>2023-01-17T12:37:06Z</dc:date>
    </item>
  </channel>
</rss>

