<?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: IF current week is blank show prior week and if prior week is blank so Not Available in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-current-week-is-blank-show-prior-week-and-if-prior-week-is/m-p/2854869#M91715</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created a sample pbix file(&lt;STRONG&gt;&lt;SPAN&gt;see attachment&lt;/SPAN&gt;&lt;/STRONG&gt;) for you, please check whether that is what you want. You can create a&amp;nbsp;&lt;STRONG&gt;measure&amp;nbsp;&lt;/STRONG&gt;as below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _selweek =
    SELECTEDVALUE ( 'Date'[Week] )
VAR _sales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        WEEKNUM ( 'Table'[Date], 2 ) = SELECTEDVALUE ( 'Date'[Week] )
    )
VAR _mindate =
    CALCULATE (
        MIN ( 'Table'[Date] ),
        FILTER ( ALL ( 'Date' ), NOT ( ISBLANK ( _sales ) ) )
    )
VAR _pwsales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( ALLSELECTED ( 'Table' ), WEEKNUM ( 'Table'[Date], 2 ) = _selweek - 1 )
    )
RETURN
    IF (
        _selweek &amp;lt; WEEKNUM ( _mindate, 2 ),
        BLANK (),
        IF (
            ISBLANK ( _sales ) &amp;amp;&amp;amp; ISBLANK ( _pwsales ),
            "Not Available",
            IF ( ISBLANK ( _sales ), _pwsales, _sales )
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&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>Fri, 21 Oct 2022 04:48:40 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-10-21T04:48:40Z</dc:date>
    <item>
      <title>IF current week is blank show prior week and if prior week is blank so Not Available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-current-week-is-blank-show-prior-week-and-if-prior-week-is/m-p/2853868#M91626</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having difficulty finding a solution to a simple logic measure. The measure will be placed in the KPI visual. The logic is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Two measures:&lt;/P&gt;&lt;P&gt;Current Week&lt;/P&gt;&lt;P&gt;Prior Week&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Logic:&lt;/P&gt;&lt;P&gt;If the current week's results are blank, show the prior week's results. If the prior week's results are blank, show "Not Available".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason the current week's results would be blank is because a portion of our data is not updated until the end of the week and everything else is updated at the beginning of the week. The reason the prior week would be blank is again the same reason except the lag between updates may move into following week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 14:08:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-current-week-is-blank-show-prior-week-and-if-prior-week-is/m-p/2853868#M91626</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-20T14:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: IF current week is blank show prior week and if prior week is blank so Not Available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-current-week-is-blank-show-prior-week-and-if-prior-week-is/m-p/2854768#M91710</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , you have few columns in date table &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;new columns &lt;BR /&gt;Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1&lt;BR /&gt;Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)&lt;BR /&gt;Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense) &lt;BR /&gt;OR&lt;BR /&gt;Week Rank RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then you can have measure like &lt;BR /&gt;This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))&lt;BR /&gt;Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The final measure can be&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if(isblank([This Week]), if(isblank([Last week]), "Not Avaiable", [Last Week]&amp;amp;""), [This Week]&amp;amp;"")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this will make your measure as text measure&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 02:58:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-current-week-is-blank-show-prior-week-and-if-prior-week-is/m-p/2854768#M91710</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-10-21T02:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: IF current week is blank show prior week and if prior week is blank so Not Available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-current-week-is-blank-show-prior-week-and-if-prior-week-is/m-p/2854869#M91715</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created a sample pbix file(&lt;STRONG&gt;&lt;SPAN&gt;see attachment&lt;/SPAN&gt;&lt;/STRONG&gt;) for you, please check whether that is what you want. You can create a&amp;nbsp;&lt;STRONG&gt;measure&amp;nbsp;&lt;/STRONG&gt;as below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _selweek =
    SELECTEDVALUE ( 'Date'[Week] )
VAR _sales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        WEEKNUM ( 'Table'[Date], 2 ) = SELECTEDVALUE ( 'Date'[Week] )
    )
VAR _mindate =
    CALCULATE (
        MIN ( 'Table'[Date] ),
        FILTER ( ALL ( 'Date' ), NOT ( ISBLANK ( _sales ) ) )
    )
VAR _pwsales =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( ALLSELECTED ( 'Table' ), WEEKNUM ( 'Table'[Date], 2 ) = _selweek - 1 )
    )
RETURN
    IF (
        _selweek &amp;lt; WEEKNUM ( _mindate, 2 ),
        BLANK (),
        IF (
            ISBLANK ( _sales ) &amp;amp;&amp;amp; ISBLANK ( _pwsales ),
            "Not Available",
            IF ( ISBLANK ( _sales ), _pwsales, _sales )
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&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>Fri, 21 Oct 2022 04:48:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-current-week-is-blank-show-prior-week-and-if-prior-week-is/m-p/2854869#M91715</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-21T04:48:40Z</dc:date>
    </item>
  </channel>
</rss>

