Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
nsadams87xx
Helper III
Helper III

Filtering data for previous months staggered back

Hello everyone,

 

I have a card visualization that I need to use to display that last two months of data.  Our scenario is that our data feeds into our mart are staggered by 14 days from the present.  So there are periods of time where we do not have complete data for the current month but also the previous month as well as the current month.  Example would be if today was October 12, we would not have a complete October obviously, but nor a September.  So my user wants to have this card display a total volume of medical patients received for the last two COMPLETE months no matter what the day.  So effectively I want to be able to calculate the total for July and August as of today.  Then then when we hit November, August and September.  Then when we hit December, September and October, etc etc.  Any suggestions?

1 ACCEPTED SOLUTION
BobBI
Resolver III
Resolver III

Create a Date Dimension , Add 'IscurrentMonth' column.

if current month is October then

Oct will be = 0

Sep will be = -1

Aug will be = -2

July will be = -3

 

then filter your report or visual basic or Advance filter to value >=-3 AND <= -2

 

you can also restrict the values like this :  value = -2 or value = -3

this is dynamically give you last 2 complted month data as per your scenerio.

 

IsCurrentMonth = IF(
                     YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY()),0,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-1,-1,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-2,-2,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-3,-3,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-4,-4,
                BLANK()  )))))

 

date table.JPG

Hope this helps

SS

View solution in original post

2 REPLIES 2
ChandeepChhabra
Impactful Individual
Impactful Individual

Hi @nsadams87xx, could you share sample data?

BobBI
Resolver III
Resolver III

Create a Date Dimension , Add 'IscurrentMonth' column.

if current month is October then

Oct will be = 0

Sep will be = -1

Aug will be = -2

July will be = -3

 

then filter your report or visual basic or Advance filter to value >=-3 AND <= -2

 

you can also restrict the values like this :  value = -2 or value = -3

this is dynamically give you last 2 complted month data as per your scenerio.

 

IsCurrentMonth = IF(
                     YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY()),0,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-1,-1,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-2,-2,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-3,-3,
                 IF(
                    YEAR('Date'[Date])=YEAR(TODAY()) && MONTH('Date'[Date]) = MONTH(TODAY())-4,-4,
                BLANK()  )))))

 

date table.JPG

Hope this helps

SS

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.