<?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 Aggregate on differente levels in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-on-differente-levels/m-p/4107697#M163005</link>
    <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for reading me. Here is my challenge. I have a measure that works just fine at the store level, but is not aggregating results on supevisors or division.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a summarized and aggregating it but it defaults to 1 the number of stores in the region returning always a calculation based on the 3rd IF.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is my measure&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Calcula la venta perdida basada en las condiciones especificadas

    IF(
        // Condición 1: Si alguno de los valores es BLANK(), devuelve BLANK()
        ISBLANK([Max%$AsAMismasComuna]) || ISBLANK([% $ AsA (Mismas)]),
        BLANK(),
        IF(
            // Condición 2: Si hay 2 o más farmacias en la comuna y el porcentaje máximo en la comuna es mayor al actual
            [# FarmaciasPorComuna] &amp;gt;= 2 &amp;amp;&amp;amp; [Max%$AsAMismasComuna] &amp;gt; [% $ AsA (Mismas)],
            // Calcula la venta perdida multiplicando la diferencia por la proyección de ventas
            CALCULATE(
                ([Max%$AsAMismasComuna] - [% $ AsA (Mismas)] ) * [$ Proyeccion]
            ),
            IF(
                // Condición 3: Si hay solo 1 farmacia en la comuna y el porcentaje máximo en la división es mayor al actual
                [Max%$AsAMismasDivision] &amp;gt; [% $ AsA (Mismas)],
                // Calcula la venta perdida multiplicando la diferencia por la proyección de ventas
                CALCULATE(
                    ( [Max%$AsAMismasDivision] - [% $ AsA (Mismas)] ) * [$ Proyeccion]
            ),
            // Si no se cumplen las condiciones, devuelve BLANK()
                BLANK()
            )
        )
   )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Any suggestions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2024 21:12:39 GMT</pubDate>
    <dc:creator>reynaldo_malave</dc:creator>
    <dc:date>2024-08-19T21:12:39Z</dc:date>
    <item>
      <title>Aggregate on differente levels</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-on-differente-levels/m-p/4107697#M163005</link>
      <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for reading me. Here is my challenge. I have a measure that works just fine at the store level, but is not aggregating results on supevisors or division.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a summarized and aggregating it but it defaults to 1 the number of stores in the region returning always a calculation based on the 3rd IF.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is my measure&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// Calcula la venta perdida basada en las condiciones especificadas

    IF(
        // Condición 1: Si alguno de los valores es BLANK(), devuelve BLANK()
        ISBLANK([Max%$AsAMismasComuna]) || ISBLANK([% $ AsA (Mismas)]),
        BLANK(),
        IF(
            // Condición 2: Si hay 2 o más farmacias en la comuna y el porcentaje máximo en la comuna es mayor al actual
            [# FarmaciasPorComuna] &amp;gt;= 2 &amp;amp;&amp;amp; [Max%$AsAMismasComuna] &amp;gt; [% $ AsA (Mismas)],
            // Calcula la venta perdida multiplicando la diferencia por la proyección de ventas
            CALCULATE(
                ([Max%$AsAMismasComuna] - [% $ AsA (Mismas)] ) * [$ Proyeccion]
            ),
            IF(
                // Condición 3: Si hay solo 1 farmacia en la comuna y el porcentaje máximo en la división es mayor al actual
                [Max%$AsAMismasDivision] &amp;gt; [% $ AsA (Mismas)],
                // Calcula la venta perdida multiplicando la diferencia por la proyección de ventas
                CALCULATE(
                    ( [Max%$AsAMismasDivision] - [% $ AsA (Mismas)] ) * [$ Proyeccion]
            ),
            // Si no se cumplen las condiciones, devuelve BLANK()
                BLANK()
            )
        )
   )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Any suggestions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 21:12:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-on-differente-levels/m-p/4107697#M163005</guid>
      <dc:creator>reynaldo_malave</dc:creator>
      <dc:date>2024-08-19T21:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate on differente levels</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-on-differente-levels/m-p/4107851#M163017</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="262058" data-lia-user-login="reynaldo_malave" class="lia-mention lia-mention-user"&gt;reynaldo_malave&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please provide more&amp;nbsp;&lt;STRONG&gt;raw data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples?&amp;nbsp;It would be helpful to find out the solution. You can refer the following links to share the required info:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7CClaire.Dong%40microsoft.com%7Cada9149bd91546a8432508dacd31ef9b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047911607737134%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=EJlYfclgtrjgAEYj9Uo1AauqxaQm3hlQsjJMo4zCY1M%3D&amp;amp;reserved=0" target="_blank"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C01%7CClaire.Dong%40microsoft.com%7Cada9149bd91546a8432508dacd31ef9b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047911607737134%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=7UEf71Mu2ySWC7MlgciaPViM1RqU5nx4OHGHG5EvNSw%3D&amp;amp;reserved=0" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;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"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Zhengdong Xu&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 01:29:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Aggregate-on-differente-levels/m-p/4107851#M163017</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-20T01:29:13Z</dc:date>
    </item>
  </channel>
</rss>

