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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
cristianml
Post Prodigy
Post Prodigy

Calculate amount depending of other table and column

Hi,

 

I need a Dax measure to calculate a difficult formula. I have 2 tables : Ad hoc table and Forecast table. Each table has a column called "Actual or Forecast" which has two possible texts: "Actual" or "Forecast".

 

Note: these 2 tables are already related/have a relationship by period and other categories.

 

What I need is a dax formula that follows this logic: Sum Amount of Ad hoc table + Amount of Forecast table till the column "Actual or Forecast" from Forecast table changes to "Forecast". In that moment I need to sum the Ad hoc amounts till the column "Actual or Forecast" from Forecast table changes to "Forecast" + the amounts of the forecast table. 

 

To understand and visualize this logic better I can show you this:

 

ad hoc Table
 Sep-18Oct-18Nov-18Dec-18Jan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19Aug-19
  Actual  Actual  Actual  Actual  Actual  Actual  Actual  Actual  Actual  Actual   
Depreciation  4,200.00  4,200.00  4,200.00  4,200.00  4,200.00  4,200.00  4,200.00  4,200.00        4,200.00        4,200.00               -                 -  

 

 

Forecast Table
 Sep-18Oct-18Nov-18Dec-18Jan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19Aug-19
  Actual  Actual  Actual  Actual  Actual  Actual  Actual  Actual ForecastForecastForecastForecast
Depreciation                4,000.00        4,000.00  4,000.00  4,000.00
Other Forecast costs  1,000.00  1,000.00  1,000.00  1,000.00  1,000.00  1,000.00  1,000.00  1,000.00        1,000.00        1,000.00  1,000.00  1,000.00
Total   1,000.00  1,000.00  1,000.00  1,000.00  1,000.00  1,000.00  1,000.00  1,000.00        5,000.00        5,000.00  5,000.00  5,000.00

 

 

  Actual  Actual  Actual  Actual  Actual  Actual  Actual  Actual ForecastForecastForecastForecast
 Sep-18Oct-18Nov-18Dec-18Jan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19Aug-19
Result Forecast  table + ad hoc table  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00        9,200.00        9,200.00  5,000.00  5,000.00
         issue hereissue here  

 

This is the correct result that it should be (Total) Actual  Actual  Actual  Actual  Actual  Actual  Actual  Actual ForecastForecastForecastForecast
Sep-18Oct-18Nov-18Dec-18Jan-19Feb-19Mar-19Apr-19May-19Jun-19Jul-19Aug-19
  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00        5,000.00        5,000.00  5,000.00  5,000.00
         Correct Correct   

 

Thanks.

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @cristianml 

Create a calendar table

calendar = ADDCOLUMNS(CALENDARAUTO(),"month-year",FORMAT([Date],"mmm-yy"),"monthnumber",FORMAT([Date],"yyyymm"))

Create relationship based on "date" column

1.png

 

Create measures

hoc_value = SUM(hoc[value])

forecast_value = SUM(forecast[value])

forecast_other_value = SUM(forecast[other value])

sum_forecast = [forecast_value]+[forecast_other_value]

final_value = IF(MAX(forecast[category])="Forecast",[sum_forecast],[hoc_value]+[sum_forecast])

2.png

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-juanli-msft ,

 

There is a value missed. The table Forecast also have "Actual" amounts that need to be included. Also I don't need to create a calendar cause my model already has this (see the  picture below). Follow the tables below for more visibility and use them as base to work on the result measure that I need (below):

 

Ad hoc table
AmountActual or ForecastDateCategory
  4,200.00 Actual 2018-09Depreciation
  4,200.00 Actual 2018-10Depreciation
  4,200.00 Actual 2018-11Depreciation
  4,200.00 Actual 2018-12Depreciation
  4,200.00 Actual 2019-01Depreciation
  4,200.00 Actual 2019-02Depreciation
  4,200.00 Actual 2019-03Depreciation
  4,200.00 Actual 2019-04Depreciation
  4,200.00 Actual 2019-05Depreciation
  4,200.00 Actual 2019-06Depreciation
               -   2019-07Depreciation
               -   2019-08Depreciation

 

Forecast Table:

Actual or ForecastAmountCategoryDate
 Actual      200.00 Technology Charges 2018-09
 Actual      800.00 Seat Charges 2018-09
 Actual   1,000.00 Per diem 2018-10
 Actual   1,000.00 Other business 2018-11
 Actual      700.00 Travel 2018-12
 Actual      300.00 Office Supplies 2018-12
 Actual      400.00 Training 2019-01
 Actual      600.00 Seat Charges 2019-01
 Actual   1,000.00 Facilities 2019-02
 Actual      500.00 Office Supplies 2019-03
 Actual      500.00 Training 2019-03
 Actual   1,000.00 Other costs 2019-04
Forecast     350.00 Travel 2019-05
Forecast     650.00 Per diem 2019-05
Forecast  4,000.00 Depreciation 2019-05
Forecast     350.00 Travel 2019-06
Forecast     650.00 Per diem 2019-06
Forecast  4,000.00 Depreciation 2019-06
Forecast     500.00 Travel 2019-07
Forecast     500.00 Per diem 2019-07
Forecast  4,000.00 Depreciation 2019-07
Forecast     500.00 Travel 2019-08
Forecast     500.00 Per diem 2019-08
Forecast  4,000.00 Depreciation 2019-08

 

Date2018-092018-102018-112018-122019-012019-022019-032019-042019-052019-062019-072019-08
Actual or forecastActualActualActualActualActualActualActualActualActualActualForecastForecast
Result (measure)   5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,200.00  5,000.00  5,000.00

 

 

Screenhoot of my real model:

Model.jpg

 

Thanks,

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors