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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
OlafA69
Frequent Visitor

Measure to

Hello,

I have an issue that seems to be pretty simple but I'm not yet able to solve it. In PowerBi I have created a table that shows Forecast and the Spent values by month. I simple need a measure that check if the month in the month column is older than todays month, then take the value from the Spent column otherwise take it from the Forecast column. I appreciate any help.

Thanks

Olaf

OlafA69_0-1695043494471.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @OlafA69 ,

 

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
var _table=
CALENDAR(
    DATE(2023,1,1),DATE(2023,12,31))
return
ADDCOLUMNS(
    _table,"Month",FORMAT([Date],"mmmm"))

vyangliumsft_0-1695204518714.png

2. Create measure.

Measure =
var _today=TODAY()
var _mindate=DATE(YEAR(_today),MONTH(_today),1)
var _maxdate=EOMONTH(_today,0)
var _date=
MAXX(FILTER(ALL('Table 2'),'Table 2'[Month]=MAX('Table'[Month])),'Table 2'[Date])
return
IF(
    _date<_mindate,SUMX(FILTER(ALL('Table'),'Table'[Month]=MAX('Table'[Month])),[Spent]),
    IF(
        _date>_maxdate,SUMX(FILTER(ALL('Table'),'Table'[Month]=MAX('Table'[Month])),[Forecast])))

3. Result:

 

vyangliumsft_1-1695204518716.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @OlafA69 ,

 

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
var _table=
CALENDAR(
    DATE(2023,1,1),DATE(2023,12,31))
return
ADDCOLUMNS(
    _table,"Month",FORMAT([Date],"mmmm"))

vyangliumsft_0-1695204518714.png

2. Create measure.

Measure =
var _today=TODAY()
var _mindate=DATE(YEAR(_today),MONTH(_today),1)
var _maxdate=EOMONTH(_today,0)
var _date=
MAXX(FILTER(ALL('Table 2'),'Table 2'[Month]=MAX('Table'[Month])),'Table 2'[Date])
return
IF(
    _date<_mindate,SUMX(FILTER(ALL('Table'),'Table'[Month]=MAX('Table'[Month])),[Spent]),
    IF(
        _date>_maxdate,SUMX(FILTER(ALL('Table'),'Table'[Month]=MAX('Table'[Month])),[Forecast])))

3. Result:

 

vyangliumsft_1-1695204518716.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

some_bih
Super User
Super User

Hi @OlafA69 check link / video from link below

https://www.sqlbi.com/articles/showing-actuals-and-forecasts-in-the-same-chart-with-power-bi/ 

Budet is similar like your forecast.

Hope this help, kudos appreciated.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.