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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
greenskmachine2
Frequent Visitor

Incorrect Total for measure

Hi team, I am aware this is a common type of question but I haven't worked how to resolve it. 


I have a situation where I need to find the latest date(s), and then sum the data based between that date and ten days prior. 


I need this to display at all times, ignoring the date slicers. Below is what I have come up with, and it does give me the correct value per Plant. But how do I adjust it so the Total is actually the sum of what's above it? 

 

SumStationRows =
 
VAR MaxDate = CALCULATE(MAXX(F_Station,F_Station[CalendarDate]),ALL(DIM_Calendar))
VAR MaxDateStart = maxDate-10

VAR CalculateSum =
CALCULATE(
    CALCULATE(SUM(F_Station[RowCount]),
        FILTER(DIM_Calendar,DIM_Calendar[CalendarDate] >= MaxDateStart && DIM_Calendar[CalendarDate] <= MaxDate)),ALL(DIM_Calendar))

RETURN
CalculateSum

 

greenskmachine2_1-1715030339222.png

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but please try something like below whether it suits your requirement.

 

SumStationRows =
VAR MaxDate =
    CALCULATE ( MAXX ( F_Station, F_Station[CalendarDate] ), ALL ( DIM_Calendar ) )
VAR MaxDateStart = maxDate - 10
VAR CalculateSum =
    SUMX (
        VALUES ( 'PlantIDtable'[PlantId] ),
        CALCULATE (
            SUM ( F_Station[RowCount] ),
            FILTER (
                ALL ( DIM_Calendar ),
                DIM_Calendar[CalendarDate] >= MaxDateStart
                    && DIM_Calendar[CalendarDate] <= MaxDate
            )
        )
    )
RETURN
    CalculateSum

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @greenskmachine2 ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but please try something like below whether it suits your requirement.

 

SumStationRows =
VAR MaxDate =
    CALCULATE ( MAXX ( F_Station, F_Station[CalendarDate] ), ALL ( DIM_Calendar ) )
VAR MaxDateStart = maxDate - 10
VAR CalculateSum =
    SUMX (
        VALUES ( 'PlantIDtable'[PlantId] ),
        CALCULATE (
            SUM ( F_Station[RowCount] ),
            FILTER (
                ALL ( DIM_Calendar ),
                DIM_Calendar[CalendarDate] >= MaxDateStart
                    && DIM_Calendar[CalendarDate] <= MaxDate
            )
        )
    )
RETURN
    CalculateSum

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.