cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
EdouSav
Frequent Visitor

GrandTOTAL wrong

Hello everyone,

I have the following DAX formula:

 

Test Landing 2 =
var __LastAccountingDate = CALCULATE(MAX(COMPTA[Accounting Date]), REMOVEFILTERS())
var __CurrentDate = MAX('Calendar'[Date])
var __Forecast = if([COMPTA]=0,[TotalBudget],CALCULATE([TotalBudget], KEEPFILTERS('Calendar'[Date] >= __LastAccountingDate)))
var __TotalAccounting = [COMPTA]
var __Result =
    IF(
        __LastAccountingDate >= date(year(__CurrentDate),MONTH(__CurrentDate),1) && __LastAccountingDate <= __CurrentDate,
        __TotalAccounting + (([TotalBudget] / DAY(EOMONTH(__CurrentDate, 0))) * (DAY(EOMONTH(__CurrentDate, 0)) - DAY(__LastAccountingDate))),
        __TotalAccounting + __Forecast
    )
return __Result

 

 

The idea is as follows: I retrieve the last accounting date from my accounting database. This allows me to determine whether or not to use the budget.

 

Then, if necessary, I calculate a prorated amount if the last accounting date is within the current month (which means we have the accounting amount plus a budget supplement to cover the remaining days of the month).

Note: If there is no amount in the accounting, I use the budget.

My question is, the formula seems correct for individual rows, but the Grand Total is incorrect.

Any ideas?

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @EdouSav,

I'd like to suggest you take a look at the Greg’s blog about measure formula with multiple aggregations if helps:

Measure Totals, The Final Word  
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @EdouSav,

I'd like to suggest you take a look at the Greg’s blog about measure formula with multiple aggregations if helps:

Measure Totals, The Final Word  
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

hi Xiaoxin Sheng

 

thanks for your help i read the post but still in error in my report, if you want i just create a new post with a we transfert link 

 

regards 

Thanks a lot

EdouSav
Frequent Visitor

anybody have a idea

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors