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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
GilesWalker
Skilled Sharer
Skilled Sharer

DAX formula not totaling correctly

Hi everyone,

 

I am having trouble with a DAX formula not summing properly. It is due to me not filtering correctly however after many days of trying different variations I cant seem to get it to work. Here is the data and formula:

Capture.JPG

 

 

This data is coming from two tables:

1. Concentrates

2. DateKey

 

The concentrates table contains the week and all the revenue columns. The DateKey contains the Financial month column. The two tables are joined with a One-Many both ways relationship on a column I made which contains the financial year (2016) and the weeks (1-53) combined, this column is in both tables.

 

What I am trying to acheive is to work out what the revenue/budget is for the month. The issue is we only measure by week, and some weeks will cross over months. An example is week five in the above picture. What I have done to combat this is create a measure which calculates the number of days in a week relative to the month:

 

Countrows YearWeek = CALCULATE(SUM(DateKey[Index 1]), DISTINCT(DateKey[Financial YearWeek]))

 

The DateKey[Index 1] is just a column containg a value of 1 for every row.

 

I then added this measure in the concentrates table as a column:

 

Days in week = [Countrows YearWeek]

 

Next I created the following measure to calculate the Daily budget:

 

Daily budget revenue = DIVIDE(SUM(Concentrates[Budget $ concentrates]),[Countrows YearWeek])

 

This was then added into the concentrates table as a column:

 

Daily budget revenue concentrates = [Daily budget revenue]

 

I then created this measure to give me the daily budgeted revenue * the days in the week dependant on the month:

 

Monthly budget concentrates = [Daily budget rev concentrates]*[Countrows YearWeek]

 

As you can see from the picture above each it works, however the total is showing too much, it should be roughly 4 million not 224 million. I beleive the reason is because I am missing something in the filtering. I have have tried adding in ALLEXCEPT for the month or the week and it still results in the same total figure.

 

Hope someone can assist.

 

Thanks,

 

Giles

 

 

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

Have you seen this post...

http://www.powerpivotpro.com/2012/03/subtotals-and-grand-totals-that-add-up-correctly/

 

I'm not quite clear how your orginal 'concentartes' table is set up?

View solution in original post

4 REPLIES 4
Sean
Community Champion
Community Champion

@GilesWalker Can you post sample data so we can try to create the same table visual as the picture you posted?

@Sean - here you go:

 

WeekCountrows YearWeekRevenue $ actualBudget $ concentratesDaily revenueDaily budget revenueDaily budget revenue concentratesFinancial monthMonthly budget concentrates
 5     Jun 
14638992786715974.756966.75$6,966.75Jul27867
27847414876612105.857146966.571429$6,966.57Jul48766
37840784876612011.142866966.571429$6,966.57Jul48766
47773914876611055.857146966.571429$6,966.57Jul48766
56993034876616550.58127.666667$6,966.57Jul41799.42857
5199303487669930348766$6,966.57Aug6966.571429
67673334876696196966.571429$6,966.57Aug48766
77861264876612303.714296966.571429$6,966.57Aug48766
87-2293848766-3276.8571436966.571429$6,966.57Aug48766
971354514876619350.142866966.571429$6,966.57Aug48766
1021055558592252777.542961$12,274.57Aug24549.14286
105105555859222111117184.4$12,274.57Sep61372.85714
Sean
Community Champion
Community Champion

Have you seen this post...

http://www.powerpivotpro.com/2012/03/subtotals-and-grand-totals-that-add-up-correctly/

 

I'm not quite clear how your orginal 'concentartes' table is set up?

@Sean - Thanks for your help with this. The link you sent through explained my issues perfectly and with a little tweaking I got it to work:

 

Monthly budget concentrates =

         IF(COUNTROWS(VALUES(Concentrates[Financial YearWeek]))=1,

                  [Daily budget rev concentrates]*[Countrows YearWeek],

                            SUMX(VALUES(Concentrates[Financial YearWeek]),

                                  [Daily budget rev concentrates]*[Countrows YearWeek]))

 

Thanks,

 

Giles

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.