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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
kmilarov
Helper II
Helper II

Measure with column filter and date range up to next period

Hi Guys,

I know there ar emany simialr topics, but still cnanot solve it for my model.

 

I have a table with few columns - one is Due Date (date format from past year up to years in the future ) and one column Critical - with 1 or 0. I want to create a measure to :

 

calluclate the number of the Critical rows (=1) for the oeriod up to whateevr months (for exampel up to 2 months ).

 

Screenshot 2024-02-25 102443.png

 

I tired Calculate , or/and Filters, coutnrows, SUM etc, but with not good success . For example :

 

CRITs = CALCULATE (
      SUM(Forecast_DB[CRITICAL]),
      DATESINPERIOD ( 'Forecast_DB'[Due Date],          -- returns period from date column
                      TODAY(),  -- starting from MAX date
                      +2,                   -- shifting it back 12 intervals
                      MONTH                  -- each interval being a month
      )
)
 
Any ideas for easy, simple solution ?

 

1 ACCEPTED SOLUTION
KhaiT
Regular Visitor

Hi @kmilarov ,

 

Your calculation should work with one minor change. 

Instead of using 'Forecast_DB'[Due Date], you'll need use a date table.

 

Here are the steps I tried:

1. Follow 'Generate with Dax' instructions here 

Create date tables in Power BI Desktop - Power BI | Microsoft Learn

 

I named by date table 'Dim_Date'

 

2. Join 'Forecast_DB'[Due Date] to 'Dim_Date'[Date]

 

3. Modify CRITs DAX to use Dim_Date

 

CRITs = CALCULATE (
      SUM(Forecast_DB[CRITICAL]),
      DATESINPERIOD ( 'Dim_Date'[Date],          -- returns period from date column
                      TODAY(),  -- starting from MAX date
                      +2,                   -- shifting it back 12 intervals
                      MONTH                  -- each interval being a month
      )
)

 

Hope this helps.

 

Thanks,

KhaiT

 

 

View solution in original post

2 REPLIES 2
KhaiT
Regular Visitor

Hi @kmilarov ,

 

Your calculation should work with one minor change. 

Instead of using 'Forecast_DB'[Due Date], you'll need use a date table.

 

Here are the steps I tried:

1. Follow 'Generate with Dax' instructions here 

Create date tables in Power BI Desktop - Power BI | Microsoft Learn

 

I named by date table 'Dim_Date'

 

2. Join 'Forecast_DB'[Due Date] to 'Dim_Date'[Date]

 

3. Modify CRITs DAX to use Dim_Date

 

CRITs = CALCULATE (
      SUM(Forecast_DB[CRITICAL]),
      DATESINPERIOD ( 'Dim_Date'[Date],          -- returns period from date column
                      TODAY(),  -- starting from MAX date
                      +2,                   -- shifting it back 12 intervals
                      MONTH                  -- each interval being a month
      )
)

 

Hope this helps.

 

Thanks,

KhaiT

 

 

Thanks , KhaiT. Your suggestion works very well. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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