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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mcornfield
Helper III
Helper III

Calculate formula not Totaling

Can anyone help me with this formula?

 

Calculate formula not totaling 

 

mcornfield_0-1615572432965.png

 

7 REPLIES 7
jameszhang0805
Resolver IV
Resolver IV

try this code :

Rev SWLY2 =
VAR _weekid52 =
    MAX ( DateTable[WeekID] ) - 52
RETURN
    SUMX (
        VALUES ( DateTable[WeekEnding] ),
        CALCULATE (
            SUM ( 'Fact Table'[Revenue Net] ),
            FILTER ( ALL ( DateTable ), DateTable[WeekID] = _weekid52 )
        )
AntrikshSharma
Super User
Super User

@mcornfield SELECTEDVALUE only return a single value and at the grand total there are no filters so you have to use MAX or MIN like this:

 

Rev =
VAR MaxDate =
    CALCULATE (
        MAX ( DateTable[WeekID] ),
        FILTER ( VALUES ( Dates[Calendar Year Number] ), [Revenue Net] <> 0 )
    )
VAR Result =
    CALCULATE (
        [Revenue Net],
        DateTable[WeekID] = MaxDate - 10,
        REMOVEFILTERS ( DateTable )
    )
RETURN
    Result

This gave me a total but the the wrong subtotals

mcornfield_0-1615818356721.png

 

@mcornfield  hmmm actually, I made a guess based on @themistoklis  code, if none of the solutions on this page works then you have to share power bi file, also make sure going forward you provided data upfront so that it save everyone's time 🙂

themistoklis
Community Champion
Community Champion

@mcornfield 

 

try this formula

 

Rev SWLY2 = 
var _weekid52 = SELECTEDVALUE(DateTable[WeekID]) - 52
return
CALCULATE(SUM('Fact Table'[Revenue Net]), FILTER(ALL(DateTable), DateTable[WeekID] =_weekid52 ))

This solution did not total either for some reason

mcornfield_1-1615818422065.png

 

Anonymous
Not applicable

Hi @mcornfield , you need use SUMX and Summarize in another measure.

 

try this

 

MeasureTotal = SUMX (
ADDCOLUMNS (
SUMMARIZE ( 'Table', 'Table'[Date] ),
"Result", [First Measure without Total]
),
[Result]
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.