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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Chorizo
Frequent Visitor

Conditional column/measure based on date

Hi all, 

 

I have a table with daily performance and estimate data as shown below: 

 

Date  Actual  Short Term Estimate  Long Term Estimate
01/06/21  0.2  0.3  0.33
02/06/21  0.3  0.3  0.33
03/06/21  0.3  0.3  0.33
04/06/21  0.2  0.3  0.33
05/06/21  0.2  0.3  0.33

... etc. 

Table1. Initial Table.

 

 

And I need display the data in below format. 

Date  Target  Actuals/Estimate  Source
Jan-21  10  8  Actual
Feb-21  10  9  Actual
Mar-21  10  10  Actual
Apr-21  10  11  Actual
May-21  10  7  Actual
Jun-21  10  10  Actual + Short Term  Estimate
Jul-21  10  9  Short Term Estimate 
Aug-21  10  9  Short Term Estimate
Sep-21  10  9   Short Term Estimate
Oct-21  10  9  Long Term Estimate
Nov-21  10  9  Long Term Estimate
Dec-21  10  9  Long Term Estimate

Table2. Final Table

 

I also created a 'Calendar' Table with column in MMM-YY format. I have created a measure SelectedDate  = SELECTEDVALUE('Calendar'[Date]). that is filtered by slicers on the report page. 

I need to create a measure called "Actuals/Estimate" that will dynamically calculate based on these conditions:

1. If the date in table2 is <= SelectedDate then  display Actuals Value. 

2. For the dates between SelectedDate+1 and End Of Month date, Use Short Term Estimate

3. For 3 months after current months use Short Term Estimate

4. For the rest of the months, use Long Term Estimate. 

5. When a selected date is September, use only Short term estimate for dates between SelectedDate+1 and End Of Year.

 

Knowing all these conditions, I have tried to create a measure, but I could not figure it out. I could not build logic that allows to compare dates between Selected date (not static, linked to date slicer)  and the dates in Table 2 to define which values I can use (Actuals or Estimates).

Any advice or solution you can propose?

 

Thanks, 

Nurbek

 

1 REPLY 1
amitchandak
Super User
Super User

@Chorizo , Based on what I got, Try like

 

Measure =
var _max = maxx(allselected('Calendar'), 'Calendar'[Date])
return
Switch( true() ,
month(_max) = 9 , Table2[Date] > _max && Table2[Date] <= date(Year(_max),12,31) , [ Short term estimate]
Table2[Date] <= _max , [Actual Value] ,
Table2[Date] > _max && Table2[Date] <= eomonth(_max,0),[Short Term Estimate] ,
Table2[Date] > eomonth(_max,0) && Table2[Date] <= eomonth(_max,3) ,[Short Term Estimate] ,
[Long Term Estimate]
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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