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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Works, very nice measure tnx!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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