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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Difference between measure and variable

Hi, 

 

I am a bit confuse about the use of a variable and the use of a measure in a measure:

Here i want to have the difference between max and min per category (a and b) and afterwards sum the differences.

example:

a 2

a 1

b 3

b 10

Normal max-min  = 10-1 =9

per cat : a = 2-1 =1

              b = 10-3 =7

Sum a +b = 8 -----> this is what i need i a card visual

 

I tried to put everyting in one measure and it does not work:

Min Max Total 2 = var MinMaxDiff = MAX(Table1[Value])-MIN(Table1[Value])
return
SUMX(VALUES(Table1[Type]);MinMaxDiff)
 
But if a tried what you described:
Min Max Diff = MAX( Table1[Value] ) - MIN( Table1[Value])
Min Max Total = SUMX( VALUES( Table1[Type] ); [Min Max Diff] )
 
then i works. Not sure why the var method does not work.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Works, very nice measure tnx!!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @Anonymous,

You can use following measure if it works:

Measure =
SUMX (
    SUMMARIZE (
        Table,
        [Type],
        "Max", MAX ( Table[Value] ),
        "Min", MIN ( Table[Value] )
    ),
    [Max] - [Min]
)

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Works, very nice measure tnx!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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