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
awolf88
Helper II
Helper II

Wrong Subtotal

Dear geniusses, 

I'm having an issue with the sub-totals once again. It seems even CHATGpt can't solve this, so I am praying that perhaps one of you can pin-point me in the right direction. 

 

Super simple Data-Setup with 3 Tables (Demo-Data Link available here: https://www.dropbox.com/scl/fo/i6oeb9mvrypo4bawjwov1/h?dl=0&rlkey=vgd213f2hh34sf6aki42s62l7



- Sales Table (Item/SalesDate/Revenue)

- OpenOrders TAble (Item/ShippingDate/Revenue)
- Budget Table (Month/Value)

 

All of them are linked via one-to-many relationships with a DimDate Table. 

awolf88_0-1686655918572.png

Now I've created a few simple measures to demonstrate my issue: 

- YTD SalesSUM(Sales[Revenue])

- OpenOrdersSUM('Open Orders'[Revenue])
- Budget 2023
sum(Budget[Budget Value])
- Remaining Budget Months = // It is June 2023 now. Here i only want to display values of future months ahead (so from July-December 2023). This is working fine

Remaining Budget = 
VAR LastDateWithSales = 
    CALCULATE(
        MAX(Sales[Sales Date]),
        ALL( Sales)
    )
VAR Result = 
    CALCULATE(
        [Budget 2023],
        KEEPFILTERS('Calendar'[Date] > LastDateWithSales)
    )

RETURN
Result

// here I want to only show future months (anything > Present month)

- S1: YTD + Open Orders // this is my very basic Scenario 1 (S1) preview of all of 2023, adding YTD Sales and adding the Open Orders outlook for the remainder of the year

S1: YTD + Open Orders = 
[YTD Sales] + [Open Orders]

 

- S2: YTD + remaining Budget: and in this next part is where it doesn't add up for me: I want to display a Scenario where I take the YTD Sales from January-May, for the current month (June) I implement the MTD Sales + Open orders within June and from July onwards I would want it to refer to the "remaining Budget" column.  

S2: YTD + remaining Budget = 

VAR CurrentMonth = MONTH(TODAY())

RETURN
IF(
    MONTH(MAX('Calendar'[Date])) = CurrentMonth,
    [S1: YTD + Open Orders],
[YTD Sales] + [Remaining Budget]
)

 

So far so good. The values per Month seem to add up to where they should be, but the Grand total of S2 should not be €1.581 as it says. It should be €1.806. What seems to be missing in the total is the value of €225 from the Open Orders in June. 

awolf88_1-1686656383645.png

Any idea why it is doing this and how I could fix it? 

 

Thank you so much for your help in advance. 

Best,

Alex

 



There is a filter on the page with Calendar[Year] = 2023 as I'm only interested on the current year. 

 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @awolf88 ,

 

Believe what you can do is a new measure with the following code:

Measure = SUMX(DISTINCT('Calendar'[MonthName]), [S2: YTD + remaining Budget])
 
MFelix_0-1686657655506.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
awolf88
Helper II
Helper II

Thank you so much, Miguel! Totally did the trick!

 

Best,

Alex

MFelix
Super User
Super User

Hi @awolf88 ,

 

Believe what you can do is a new measure with the following code:

Measure = SUMX(DISTINCT('Calendar'[MonthName]), [S2: YTD + remaining Budget])
 
MFelix_0-1686657655506.png

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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!

November Carousel

Fabric Community Update - November 2024

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

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.