<?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: Lookup in a Tabular Model with direct query in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3642773#M141031</link>
    <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your answer.&lt;BR /&gt;Yes, sorry if that was confusing. I just wanted to show everything that came back from ChatGPT, which did not work.&lt;BR /&gt;&lt;BR /&gt;I have a table with a dimension with members a to d, splitting up a measure.&lt;BR /&gt;Now I want to calculate for every row the percentage of the current row's measure value divided by the previous row, except for the last row&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Dimension&lt;/TD&gt;&lt;TD&gt;Measure&lt;/TD&gt;&lt;TD&gt;Pct&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;98&lt;/TD&gt;&lt;TD&gt;b/a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;TD&gt;c/b&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;d/a&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I look up the value of the previous or the first row without making the table dimension header filter out the value of the other row?&lt;BR /&gt;I have a Tabular Model and Direct Query. The measure is the count of a table, and it is not the same table the dimension is coming from. Is this possible in PowerBI on a Tabular Model, or would I need a calculated column?&lt;BR /&gt;&lt;BR /&gt;I hope this makes my use case more evident.&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Matthias&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jan 2024 06:53:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-01-17T06:53:41Z</dc:date>
    <item>
      <title>Lookup in a Tabular Model with direct query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3641670#M140991</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;I am new to the Tabular Model and relatively new to DAX.&lt;BR /&gt;&lt;BR /&gt;I do have a tabular model, and I want to calculate this&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Stage (from 'PipelineStages'[Stage]&lt;/TD&gt;&lt;TD&gt;SalesFunnel (SUM(_RequestbyStage[RowCount]))&lt;/TD&gt;&lt;TD&gt;Pct of previous&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Registration&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;blank&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Enquiry&lt;/TD&gt;&lt;TD&gt;479&lt;/TD&gt;&lt;TD&gt;95.8 %&amp;nbsp; --&amp;gt; 479 / 500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Visited&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;TD&gt;6.9 % --&amp;gt; 33/479&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Lost&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;80.0 % !!! Lost/Registration 400/500&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is using ChatGPT; when I try just to get the SalesFunnel value of the above row, I either get&lt;BR /&gt;&lt;BR /&gt;a value on every row which is identical to the SalesFunnel of the same line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF ( 
     CALCULATETABLE( 
                    VALUES(_PipelineStages[Stage]); _PipelineStages[Stage] = "Lost" 
                           ) = "Lost"; 
                    CALCULATE([Sales Funnel]); BLANK() 
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;just blanks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF (
    SELECTEDVALUE(_PipelineStages[Stage]) = "Lost";
    CALCULATE([Sales Funnel]);
    BLANK()
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or it yields an error "&lt;SPAN&gt;a table of multiple values war supplied where a single value was expected":&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF (
    VALUES(_PipelineStages[Stage]) = "Lost",
    [Sales Funnel],
    BLANK()
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;or there seems something wrong with RELATEDTABLE(PipelineStages)[Stage] Syntax or it could be that it's because this table is invisible:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF (
    RELATEDTABLE(_PipelineStages)[Stage] = "Lost";
    CALCULATE([Sales Funnel]);
    BLANK()
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;any help is highly welcome. Even if the finding is this is impossible in a tabular model with a direct query using PowerBI to debug.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks,&amp;nbsp;&lt;BR /&gt;Matthias&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 18:47:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3641670#M140991</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-16T18:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup in a Tabular Model with direct query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3642654#M141025</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you clearly describe your needs? From the four dax formulas you gave, I can only know that these four formulas are trying to achieve the same goal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the dax formula you gave, I can give you a few suggestions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.There is a problem with the arguments in the CALCULATETABLE function,&amp;nbsp;This is the correct usage of the expression&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;CALCULATETABLE&lt;SPAN&gt;(&amp;lt;expression&amp;gt;[, &amp;lt;filter1&amp;gt; [, &amp;lt;filter2&amp;gt; [, …]]])&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/calculatetable-function-dax" target="_blank" rel="noopener"&gt;CALCULATETABLE function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;2.The argument in the calculate function cannot be a column,&amp;nbsp;This is the correct usage of the expression&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;SPAN class=""&gt;CALCULATE(&amp;lt;expression&amp;gt;[, &amp;lt;filter1&amp;gt; [, &amp;lt;filter2&amp;gt; [, …]]])&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/calculate-function-dax" target="_blank"&gt;CALCULATE function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P data-unlink="true"&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;Jayleny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&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;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 06:04:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3642654#M141025</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-17T06:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup in a Tabular Model with direct query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3642773#M141031</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your answer.&lt;BR /&gt;Yes, sorry if that was confusing. I just wanted to show everything that came back from ChatGPT, which did not work.&lt;BR /&gt;&lt;BR /&gt;I have a table with a dimension with members a to d, splitting up a measure.&lt;BR /&gt;Now I want to calculate for every row the percentage of the current row's measure value divided by the previous row, except for the last row&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Dimension&lt;/TD&gt;&lt;TD&gt;Measure&lt;/TD&gt;&lt;TD&gt;Pct&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;98&lt;/TD&gt;&lt;TD&gt;b/a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;TD&gt;c/b&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;d/a&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I look up the value of the previous or the first row without making the table dimension header filter out the value of the other row?&lt;BR /&gt;I have a Tabular Model and Direct Query. The measure is the count of a table, and it is not the same table the dimension is coming from. Is this possible in PowerBI on a Tabular Model, or would I need a calculated column?&lt;BR /&gt;&lt;BR /&gt;I hope this makes my use case more evident.&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Matthias&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 06:53:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3642773#M141031</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-17T06:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup in a Tabular Model with direct query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3651038#M141436</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Use the following code in power query&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTI0MFCK1YlWSgKyLS3AzGQg0wQimgJkGgOZsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Dimension = _t, Measure = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dimension", type text}, {"Measure", Int64.Type}}),
    RowCount = Table.RowCount(Source),
    
    SourceWithIndex = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
   
    Custom = Table.AddColumn(SourceWithIndex, "CustomMeasure", each 
        let
            currentIndex = [Index],
            currentMeasure = [Measure],
            prevMeasure = if currentIndex &amp;gt; 0 then SourceWithIndex{currentIndex - 1}[Measure] else null,         
            firstMeasure = SourceWithIndex{0}[Measure],      
            lastMeasure = SourceWithIndex{RowCount - 1}[Measure],     
            result = if currentIndex = RowCount - 1 then currentMeasure / firstMeasure else currentMeasure / prevMeasure
        in
            result, type number),
    #"Filtered Rows" = Table.SelectRows(Custom, each true)
in
    #"Filtered Rows"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the result you want&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jayleny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&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;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 07:57:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3651038#M141436</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-22T07:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup in a Tabular Model with direct query</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3651208#M141452</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you a lot for coming back to me.&lt;BR /&gt;In the meantime, I could solve the calculation partly using DAX with the new table calculation capabilities using OFFSET. I did not want to work with additional tables or columns.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Var PrevValue = CALCULATE([Sales];
                                    OFFSET(-1; 
                                    ALLSELECTED(DimTab[Rank];DimTab[Dim]);  
                                    OrderBy(DimTab[Rank]; ASC))
                                    ) &lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;This works perfectly fine.&lt;BR /&gt;Thank you again for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 08:57:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-in-a-Tabular-Model-with-direct-query/m-p/3651208#M141452</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-22T08:57:57Z</dc:date>
    </item>
  </channel>
</rss>

