<?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: calculate and sameperiodlastyear not working IF function in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2963954#M40268</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/416804"&gt;@abbytank&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can &lt;STRONG&gt;update&lt;/STRONG&gt; the formula of measure [Previous_year_sales] as below, please notice that the data type of returned result will be &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt; &lt;/FONT&gt;type &lt;STRONG&gt;instead of&lt;/STRONG&gt; Number type. If you still want to keep the data type as &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Number&lt;/STRONG&gt; &lt;/FONT&gt;type, you can change "&lt;EM&gt;&lt;STRONG&gt;No Sales&lt;/STRONG&gt;&lt;/EM&gt;" to &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Previous_year_sales =
VAR _pysales =
    CALCULATE ( [TotalSales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
RETURN
    IF ( ISBLANK ( _pysales ), "No Sales", _pysales )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_0-1670901130132.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/839641i893F0093876546ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="yingyinr_0-1670901130132.png" alt="yingyinr_0-1670901130132.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;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, 13 Dec 2022 03:12:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-12-13T03:12:44Z</dc:date>
    <item>
      <title>calculate and sameperiodlastyear not working IF function</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2961530#M40243</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hi,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am having issue with the following calculation, I want to calculate the total sales, which is working correct, but when I select a year whose previous year had no sales like the initial year, it show blank, I needed to use if to avoid showing blank, but it returned error. Here is the code:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;Previous_year_sales = &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;"No Sales"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[TotalSales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;SPAN&gt;Please someone help.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Dec 2022 06:12:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2961530#M40243</guid>
      <dc:creator>abbytank</dc:creator>
      <dc:date>2022-12-12T06:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: calculate and sameperiodlastyear not working IF function</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2963954#M40268</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/416804"&gt;@abbytank&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can &lt;STRONG&gt;update&lt;/STRONG&gt; the formula of measure [Previous_year_sales] as below, please notice that the data type of returned result will be &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt; &lt;/FONT&gt;type &lt;STRONG&gt;instead of&lt;/STRONG&gt; Number type. If you still want to keep the data type as &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Number&lt;/STRONG&gt; &lt;/FONT&gt;type, you can change "&lt;EM&gt;&lt;STRONG&gt;No Sales&lt;/STRONG&gt;&lt;/EM&gt;" to &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Previous_year_sales =
VAR _pysales =
    CALCULATE ( [TotalSales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
RETURN
    IF ( ISBLANK ( _pysales ), "No Sales", _pysales )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_0-1670901130132.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/839641i893F0093876546ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="yingyinr_0-1670901130132.png" alt="yingyinr_0-1670901130132.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;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, 13 Dec 2022 03:12:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2963954#M40268</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-13T03:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: calculate and sameperiodlastyear not working IF function</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2966178#M40294</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;@Anonymous&amp;nbsp; for your supportive response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see your solutions is 100% working and providing the very desired result, but concern is:&lt;/P&gt;&lt;P&gt;This is working:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _pysales =
    CALCULATE ( [TotalSales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
return _pysales&lt;/LI-CODE&gt;&lt;P&gt;And also, the following is working:&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;And even the first the part of the code is working, because when the previous years sales is empty (no sales on previous year) the result is working and showing "No Sales" result:&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;Previous_year_sales = &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;"No Sales"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the problem is, when the calculate function or even sumx function put on the IF functions as (if function's) return values (return values on true or false) according to the following:&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;Previous_year_sales = &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;"No Sales"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[TotalSales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;So, why calculate is not working in IF function's argument, that is my concern?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 18:58:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2966178#M40294</guid>
      <dc:creator>abbytank</dc:creator>
      <dc:date>2022-12-13T18:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: calculate and sameperiodlastyear not working IF function</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2978676#M40393</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/416804"&gt;@abbytank&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Actually, the function &lt;STRONG&gt;ISBLANK&lt;/STRONG&gt; is to check&amp;nbsp;whether &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;a value&lt;/STRONG&gt;&lt;/FONT&gt; is blank. But it will return&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt; a table&lt;/FONT&gt;&lt;/STRONG&gt; when you apply the function&amp;nbsp;SAMEPERIODLASTYEAR. You can find the details in the following links.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/isblank-function-dax" target="_self"&gt;ISBLANK&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/sameperiodlastyear-function-dax" target="_self"&gt;SAMEPERIODLASTYEAR&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 10:05:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/calculate-and-sameperiodlastyear-not-working-IF-function/m-p/2978676#M40393</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-20T10:05:12Z</dc:date>
    </item>
  </channel>
</rss>

