<?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 restar solo en el caso de CONTRATO y PEDIDO o CONTRATO y MITEL in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4361480#M173149</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;DAX hacer resta solo si tiene 2 tipos&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;2 hours ago&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;SPAN&gt;Estoy trabajando en powerbi, tengo una tabla de varios proyectos con su codigo proyecto, el importebaseimponible y tipo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Solo hay 3 tipos, CONTRATO, PEDIDO y MITEL.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Codigoproyecto= 'ProyectosUnificados'[CodigoProyecto]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Importebaseimponible= 'ProyectosUnificados'[ImporteBaseImponible]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tipo= 'ProyectosUnificados'[Tipo]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Quiero crear una columna calculada con dax que lo que haga sea:&amp;nbsp;si un mismo codigoproyecto tiene tipo PEDIDO&amp;nbsp; y ademas tipo CONTRATO, que se reste el importebaseimponible de CONTRATO a PEDIDO&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Y lo mismo con MITEL,&amp;nbsp;&lt;SPAN&gt;si un mismo codigoproyecto tiene tipo MITEL y ademas tipo CONTRATO, que se reste el importebaseimponible de CONTRATO a MITEL&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;basicamente si es contrato y ademas otro tipo, que se reste lo de contrato al otro tipo que tenga.&lt;BR /&gt;&lt;BR /&gt;Ahora mismo me sale esto sin hacer la resta, lo que quiero es que contratos se mantenga igual, pero en mitel y pedido deberian hacerse las restas y deberia ser un numero menor.&lt;/P&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;En los proyectos que solo tienen un tipo o son MITELy PEDIDO, como no hay contrato y otro tipo, que se mantenga el importebaseimponible que ya tiene, simplemente no se hace la resta.&lt;BR /&gt;&lt;BR /&gt;llevo dias con esto, agradeceria una solucion, muchas gracias de antemano, me duele la cabeza de intentar conseguirlo y que no salge jeje, espero que me puedan ayudar porfavor&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 13 Jan 2025 12:11:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2025-01-13T12:11:47Z</dc:date>
    <item>
      <title>restar solo en el caso de CONTRATO y PEDIDO o CONTRATO y MITEL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4361480#M173149</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;DAX hacer resta solo si tiene 2 tipos&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;2 hours ago&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;SPAN&gt;Estoy trabajando en powerbi, tengo una tabla de varios proyectos con su codigo proyecto, el importebaseimponible y tipo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Solo hay 3 tipos, CONTRATO, PEDIDO y MITEL.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Codigoproyecto= 'ProyectosUnificados'[CodigoProyecto]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Importebaseimponible= 'ProyectosUnificados'[ImporteBaseImponible]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tipo= 'ProyectosUnificados'[Tipo]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Quiero crear una columna calculada con dax que lo que haga sea:&amp;nbsp;si un mismo codigoproyecto tiene tipo PEDIDO&amp;nbsp; y ademas tipo CONTRATO, que se reste el importebaseimponible de CONTRATO a PEDIDO&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Y lo mismo con MITEL,&amp;nbsp;&lt;SPAN&gt;si un mismo codigoproyecto tiene tipo MITEL y ademas tipo CONTRATO, que se reste el importebaseimponible de CONTRATO a MITEL&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;basicamente si es contrato y ademas otro tipo, que se reste lo de contrato al otro tipo que tenga.&lt;BR /&gt;&lt;BR /&gt;Ahora mismo me sale esto sin hacer la resta, lo que quiero es que contratos se mantenga igual, pero en mitel y pedido deberian hacerse las restas y deberia ser un numero menor.&lt;/P&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;En los proyectos que solo tienen un tipo o son MITELy PEDIDO, como no hay contrato y otro tipo, que se mantenga el importebaseimponible que ya tiene, simplemente no se hace la resta.&lt;BR /&gt;&lt;BR /&gt;llevo dias con esto, agradeceria una solucion, muchas gracias de antemano, me duele la cabeza de intentar conseguirlo y que no salge jeje, espero que me puedan ayudar porfavor&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 13 Jan 2025 12:11:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4361480#M173149</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-13T12:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: restar solo en el caso de CONTRATO y PEDIDO o CONTRATO y MITEL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4361567#M173156</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Ah, I see what you're trying to do, and it’s a common scenario when dealing with projects that can have multiple types, where you want to adjust the amounts based on whether the same project includes a "CONTRATO" type alongside another type like "PEDIDO" or "MITEL." The solution here is to create a calculated column in DAX that checks if a project code has both types present. If it finds "CONTRATO," it should subtract that base amount from the "PEDIDO" or "MITEL" amounts accordingly. Let me walk you through the DAX formula step by step.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First, we need a variable to calculate the "CONTRATO" amount for each project. We do this using the CALCULATE function to filter only rows with the "CONTRATO" type within the same project code group. Here's how that part looks in DAX:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR ContratoAmount =
    CALCULATE(
        SUM('ProyectosUnificados'[ImporteBaseImponible]),
        'ProyectosUnificados'[Tipo] = "CONTRATO",
        ALLEXCEPT('ProyectosUnificados', 'ProyectosUnificados'[CodigoProyecto])
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;The ALLEXCEPT function ensures that the calculation respects the project code grouping, so it doesn’t go off calculating for unrelated projects.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now, once we have the "CONTRATO" amount for each project, we can use an IF statement to check if the current row’s type is either "PEDIDO" or "MITEL." If it is, we subtract the "CONTRATO" amount from the current row’s base amount. Otherwise, we leave the original amount unchanged. Here’s the full DAX formula for the calculated column:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ImporteAjustado =
IF(
    'ProyectosUnificados'[Tipo] IN {"PEDIDO", "MITEL"},
    'ProyectosUnificados'[ImporteBaseImponible] - ContratoAmount,
    'ProyectosUnificados'[ImporteBaseImponible]
)
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;What this formula does is adjust the amounts for "PEDIDO" and "MITEL" types by subtracting the corresponding "CONTRATO" amount, but only when both types exist for the same project. If a project doesn’t have a "CONTRATO" type, the original amount remains unchanged, as you wanted.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To put it simply, this DAX formula ensures that the subtraction happens only when there are two types for the same project. For projects that don’t have a "CONTRATO" type, the amounts for "PEDIDO" and "MITEL" stay as they are.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 13:14:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4361567#M173156</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2025-01-13T13:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: restar solo en el caso de CONTRATO y PEDIDO o CONTRATO y MITEL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4361807#M173171</link>
      <description>&lt;P&gt;Muchas gracias por la explicacion!&lt;BR /&gt;&lt;BR /&gt;Pero no entiendo porque me da negativo en Pedido,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lo que quisiera hacer es que si un proyecto es tipo pedido y contrato, que al de pedido se le reste lo de contrato&lt;BR /&gt;&lt;BR /&gt;Y con MItel igual, Que si un proyecto es tipo Mitel y contrato, se le reste lo de contrato a mitel.&lt;BR /&gt;&lt;BR /&gt;y si no es ninguno de los 2 casos que ese proyecto se quede con el importebaseimponible igual, en total deberia dar mas o menos 228k en mitel (se le habria restado 73k aproximadamente para dar este resultado) y en pedidos deberia dar 964k aproximadamente, (para que de ese numero se le tendria que haber restado 239k de contratos aproximadamente)&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 15:17:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4361807#M173171</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-13T15:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: restar solo en el caso de CONTRATO y PEDIDO o CONTRATO y MITEL</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4362819#M173208</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Based on your description, it appears that you need to calculate the result of a subtraction with the type CONTRACT when the type is either ORDER or MITEL. Could you please provide some sample data from the&amp;nbsp;&lt;/SPAN&gt;table&amp;nbsp;&lt;SPAN&gt;'ProyectosUnificados' (&lt;EM&gt;&lt;STRONG&gt;excluding any sensitive information&lt;/STRONG&gt;&lt;/EM&gt;) in &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;TEXT&lt;/STRONG&gt; &lt;/FONT&gt;format, along with your expected result, backend logic, and any special examples? This information will be helpful in identifying a solution. You can refer to the following link to share the required details:&amp;nbsp;&amp;nbsp;&lt;/SPAN&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-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" rel="nofollow noopener noreferrer"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;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, 14 Jan 2025 07:47:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/restar-solo-en-el-caso-de-CONTRATO-y-PEDIDO-o-CONTRATO-y-MITEL/m-p/4362819#M173208</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-14T07:47:53Z</dc:date>
    </item>
  </channel>
</rss>

