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
ppaiva
Regular Visitor

How to Sum a min measure

Hi, 

I'm trying to create a Measure that gives SUM of MINs under 2 different geography levels, but I couldn't sort it out after many attempts.

 

This is my table and data example

 

Geo1Geo2CategoryComponentQty
AA1CAT1Comp11
AA1CAT1Comp22
AA1CAT2Comp13
AA1CAT2Comp24
AA2CAT1Comp15
AA2CAT1Comp26
AA2CAT2Comp17
AA2CAT2Comp28

 

This is the desired Measure output for 2 different configurations:


First Case:

Geo1CategoryResult Measure Desired
ACAT16
ACAT210

 

I expect this result because:

For Geo1 = A, Category = CAT1,

Sum(Comp1)=6, Sum(Comp2)=8

Min(6,8) = 6

 

Second case:

Geo1Geo2CategoryResult Measure Desired
AA1CAT11
AA1CAT23
AA2CAT15
AA1CAT27

 

I expect this result because:

For Geo1 = A, Geo2 = A1, Category = CAT1,

Sum(Comp1)=1, Sum(Comp2)=2

Min(1,2) = 1

 

For Geo1 = A, Geo2 = A2, Category = CAT1,

Sum(Comp1)=5, Sum(Comp2)=6

Min(5,6) = 5

 

Basically what I'm trying to do is to check at Geo1 Level and Category what's the minimum number of components available, and from there define the category result. 

 

If I add Geo2, I pretend to have this measure reconstructed to recalculate the equation at that level.

 

In a practical example, if for Geo1 = US, CAT1 = PC, I have COMP1 = SCREEN, COMP2 = KEYBOARD, the minimum number of available PCs in US is equal to the minimum of SCREENs and KEYBOARDs in US, independently if they are in different cities. But I want to check the quantities of PCs that I have in Geo2 = New York City, the number would be the minimum of components in that city only. Hope it makes sense Smiley Happy

 

I tried this option without any logic result:

Measure = 
SUMX ( 
VALUES ('Table'[Category]),
(
CALCULATE(
MINX(
SUMMARIZE('Table','Table'[Geo1],'Table'[Category],'Table'[Component],"XX",
SUM('Table'[Qty]))
,[XX])))
)

And this one:

Measure2 = MINX(
SUMMARIZE('Table','Table'[Geo1],'Table'[Category],'Table'[Component],"XX",
SUM('Table'[Qty]))
,[XX])

This last one works ok if I have Geo2 level, but if I remove it, the result is not recalculating at Geo1

 

I would appreciate some help.

Thanks and regards,
Pablo

1 REPLY 1
Anonymous
Not applicable

What about something like this:

Min Measure = 
CALCULATE(
    MINX(
        ADDCOLUMNS(
            SUMMARIZE( 
                Table1,
                Table1[Category],
                Table1[Geo1],
                Table1[Component]
            ),
            "Min", 
            CALCULATE(
                SUM( Table1[Qty])
            )
        ), 
        [Min]
    )
)

MINX of Summarize.png

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.