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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.