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
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
New Member

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
New Member

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.