<?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: Final cost based on percentage of total in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Final-cost-based-on-percentage-of-total/m-p/767958#M3544</link>
    <description>&lt;P&gt;Solved changing columns by a measure with the same formulas after struggling for hours....&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2019 20:06:11 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-08-15T20:06:11Z</dc:date>
    <item>
      <title>Final cost based on percentage of total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Final-cost-based-on-percentage-of-total/m-p/767905#M3541</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble trying to calculate a final cost based on computer usage by an user per month.&lt;/P&gt;&lt;P&gt;Let's imagine the following scenario:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a lan-house with customers that use the computers for a certain amount of time, but my billing system doesn't give me the cost ($) for each user session, only by billing period.&lt;/P&gt;&lt;P&gt;I need to get the cost for each customer to pay, by billing period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tables scenario:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;A table for billing. Each day of a machine within a billing period (e.g. day Jan 15th to Feb 15th, Feb 15th to Mar 15th) has a cost.&lt;/SPAN&gt;&lt;/LI&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;Each machine has a set of tags, in which I want to have only those tagged with "LAN"&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I have multiple billing periods, which I want to filter to see one or more than one billing period&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;LI&gt;&lt;SPAN&gt;A table for sessions log. I have the session start date and session end date with the session duration.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have so far:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;* A measure to sum all values with "LAN" tag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Invoiced USD = CALCULATE(SUM(Billing[Cost]),CONTAINSSTRING(Billing[Tag],"LAN"))&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;* A calculated table to get the sum of session duration by customer and billing period&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sessions_Consolid = SUMMARIZE(Sessions,'Sessions'[Customer],'Sessions'[Billing period],"customer.billingperiod",CONCATENATE('Sessions'[Customer],CONCATENATE(".",'Sessions'[Billing period])),"User acum. session duration",SUM('Sessions'[Session duration]))&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;* A relationship between Sessions_Consolid and Sessions table on column customer.billingperiod (filter on both directions)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;* A measure to get the total session time&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Total session duration = CALCULATE(SUM(Sessions_Consolid[User acum. session duration]),ALLSELECTED())&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;* A calculated column to get the weight of each customer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Weight = DIVIDE(Sessions_Consolid[User acum. session duration],CALCULATE([Total session duration],ALLSELECTED()),BLANK())&lt;/PRE&gt;&lt;P&gt;Could have created a measure here. I also tried, the same way I created the column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*&amp;nbsp;&lt;SPAN&gt;A measure to calculate the final value for each customer to pay&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Final value = SUM(Sessions_Consolid[Weight]) * [Invoiced USD]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to do is:&lt;/P&gt;&lt;P&gt;I have some billing periods. When I filter on a slicer any billing period, or date, or whatever, I want it to give me the cost for that period and the weight of each customer for this select period.&lt;/P&gt;&lt;P&gt;On the images below I show that behavior. When no billing period is selected,the final value total is $ 154.60, with the Weight sum resulting 1.00.&lt;/P&gt;&lt;P&gt;When I select any value on the slicer, the total session duration changes but the weight formula is considering the "Total session duration" for all values, not the only showing on the table, and the final value considers this weight over total (not only the period I want) to calculate over the Invoiced USD column. As you can see, it results 34,61 (Final value) which is 61% (Sum of Weight) of 55,84 (Invoiced USD and the desired Final value).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the link to download the .pbix with dataset&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AlvWPQ8oZ0EVgtp4qbOvcxRL9hGWOQ?e=0NyCnN" target="_self"&gt;https://1drv.ms/u/s!AlvWPQ8oZ0EVgtp4qbOvcxRL9hGWOQ?e=0NyCnN&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:08:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Final-cost-based-on-percentage-of-total/m-p/767905#M3541</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-15T19:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Final cost based on percentage of total</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Final-cost-based-on-percentage-of-total/m-p/767958#M3544</link>
      <description>&lt;P&gt;Solved changing columns by a measure with the same formulas after struggling for hours....&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 20:06:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Final-cost-based-on-percentage-of-total/m-p/767958#M3544</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-15T20:06:11Z</dc:date>
    </item>
  </channel>
</rss>

