<?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 Matrix, custom calculation in Total Column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1867456#M39993</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;I have test data like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: you can download pbix file &lt;A href="https://gofile.io/d/2qSyDf" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Scenario:&lt;BR /&gt;Users are being interviewed and it is possible that the same user gets interviewed multiple times during a month.&lt;BR /&gt;Users are providing Yes/No answers (represented by 1 and 0, respectively) in a questionnaire that has multiple questions.&lt;/P&gt;&lt;P&gt;Requirement:&lt;BR /&gt;Matrix should display all results for interviews that occured in the selected month, regardless how many questionnaires were submitted.&lt;BR /&gt;However, in TOTAL column we need to count how many users answered with Yes on certain question, but using only the latest response. (If there are muliple answers by same users, previos responses should be ignored in the calculation).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So, in the example below, expected Total in the first row should be 2 and in the second row it should be 0.&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;Please help!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 May 2021 11:56:21 GMT</pubDate>
    <dc:creator>nenadpekec</dc:creator>
    <dc:date>2021-05-27T11:56:21Z</dc:date>
    <item>
      <title>Matrix, custom calculation in Total Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1867456#M39993</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I have test data like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: you can download pbix file &lt;A href="https://gofile.io/d/2qSyDf" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Scenario:&lt;BR /&gt;Users are being interviewed and it is possible that the same user gets interviewed multiple times during a month.&lt;BR /&gt;Users are providing Yes/No answers (represented by 1 and 0, respectively) in a questionnaire that has multiple questions.&lt;/P&gt;&lt;P&gt;Requirement:&lt;BR /&gt;Matrix should display all results for interviews that occured in the selected month, regardless how many questionnaires were submitted.&lt;BR /&gt;However, in TOTAL column we need to count how many users answered with Yes on certain question, but using only the latest response. (If there are muliple answers by same users, previos responses should be ignored in the calculation).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So, in the example below, expected Total in the first row should be 2 and in the second row it should be 0.&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;Please help!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 11:56:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1867456#M39993</guid>
      <dc:creator>nenadpekec</dc:creator>
      <dc:date>2021-05-27T11:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, custom calculation in Total Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1867632#M39998</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// This measure shows how many users
// answered 'Yes' to at least one question
// (and this 'Yes' must be the latest
// answer).
// **Everything is relative to
// the current context, of course.**
// So, if you slice by Question, User and
// Date, you'll replicate the matrix you've
// shown but also the totals will be according
// to your definition.

[Your Measure] =
// We want to count the users whose
// latest answer is 'Yes' to at least
// one question in scope.
var UserQuestionWithLatestResponseDate =
    ADDCOLUMNS(
        SUMMARIZE(
            T,
            T[User],
            T[Question]
        ),
        "@LatestResponseDate",
            CALCULATE( MAX( T[Date] ) )
    )
var CountOfUsersWithAtLeastOneQWithYesA =
    CALCULATE(
        DISTINCTCOUNT( T[User] ),
        TREATAS(
            UserQuestionWithLatestResponseDate,
            T[User],
            T[Question],
            T[Date]
        ),
        KEEPFILTERS( T[Value] = 1 )
    )
return
    CountOfUsersWithAtLeastOneQWithYesA + 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It wolud be equally as easy to write a measure which would count users with all questions (in scope) answered with "Yes." And if you sliced such a measure the way the matrix is, the outcome would be the same as for the measure above.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Please bear in mind the definition of the measure when you view the measure's values. The measure is correct and does what you want but you have to read well its description to realize it's doing what it's supposed to. One last screenshot:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 14:03:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1867632#M39998</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-27T14:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, custom calculation in Total Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1867641#M39999</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="177388" data-lia-user-login="nenadpekec" class="lia-mention lia-mention-user"&gt;nenadpekec&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check the below picture and the sample pbix file's link down below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;EM&gt;Values Latest Measure = &lt;/EM&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;VAR currentq =&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;MAX ( 'Table'[Questions] )&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;VAR currentuser =&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;MAX ( 'Table'[User] )&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;VAR latestdate =&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;MAX ( 'Table'[Date] ),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;FILTER (&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;ALLSELECTED ( 'Table' ),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;'Table'[Questions] = currentq&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;amp;&amp;amp; 'Table'[User] = currentuser&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;CALCULATE (&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;SUM ( 'Table'[Value] ),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;FILTER (&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;ALLSELECTED ( 'Table' ),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;'Table'[Questions] = currentq&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;amp;&amp;amp; 'Table'[User] = currentuser&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;amp;&amp;amp; 'Table'[Date] = latestdate&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;EM&gt;Values Latest Measure Total Fix = &lt;/EM&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;IF (&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;ISFILTERED ( 'Table'[Date] ),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;SUM ( 'Table'[Value] ),&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;SUMX ( VALUES ( 'Table'[User] ), [Values Latest Measure] )&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;A href="https://www.dropbox.com/s/x8bqwbamv74yeoz/Test1.pbix?dl=0" target="_self"&gt;https://www.dropbox.com/s/x8bqwbamv74yeoz/Test1.pbix?dl=0&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;FONT face="”calibri" color="”#0000FF”"&gt;&lt;STRONG&gt;Hi, My name is Jihwan Kim. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;FONT face="”calibri" color="”#0000FF”"&gt;&lt;STRONG&gt;If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up. &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;FONT face="”calibri" color="”#0000FF”"&gt;Linkedin: linkedin.com/in/jihwankim1975/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="”calibri" color="”#0000FF”"&gt;Twitter: twitter.com/Jihwan_JHKIM&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 27 May 2021 13:02:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1867641#M39999</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2021-05-27T13:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Matrix, custom calculation in Total Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1868081#M40020</link>
      <description>&lt;P&gt;Thank you, very much!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 15:58:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Matrix-custom-calculation-in-Total-Column/m-p/1868081#M40020</guid>
      <dc:creator>nenadpekec</dc:creator>
      <dc:date>2021-05-27T15:58:24Z</dc:date>
    </item>
  </channel>
</rss>

