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
Midguel
Helper I
Helper I

sum values of a list of unique values

Hello, I'm having trouble displaying a list of unique values for a second line of code that sum only the Lbs of values in that list, here is my code:

Total LT = 
VAR list = CALCULATE(VALUES('DATA BASE'[OP]),'DATA BASE'[EE] = "LT")
RETURN
CALCULATE(SUM('DATA BASE'[Lbs]),'DATA BASE'[OP]=list)

here's a example of my data base (is a lot more bigger):

exa.PNG

i want the list of the OP's that has some value in EE = LT, for later sum the total Lbs of that OP

 

Thanks

2 ACCEPTED SOLUTIONS

Hi @Midguel ,

 

Try this measure:

 

Measure = CALCULATE(SUM('Table'[Lbs]); SELECTCOLUMNS(CALCULATETABLE('Table'; 'Table'[EE] = "LT"); "OP"; 'Table'[OP]))
 

If you consider it as a solution, please mark as a solution and kudos.

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

Hi @Midguel ,

 

Please try the below measure:

 

CALCULATE (
   [Total LBS],
    FILTER (
        SUMMARIZE (
           'Data Base',
            'Data Base'[OP],
            'Data Base'[EE],
            "OP1",
            IF (
                'Data Base'[EE]
                 =
                    "LT",
                    1,
                    0
            )
        ),
       [OP1]
         =
            1
    )
)

 

123.JPG

 

Regards,

Harsh Nathani

 

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @Midguel ,

 

You can use the below measures.

 

Total LBS = SUM('Data Base'[LBS])
 
 
TOTAL LBS BY OP = CALCULATE(
[Total LBS],
FILTER(ALLEXCEPT('Data Base','Data Base'[OP]),'Data Base'[EE] = "LT"))
 
1.JPG
 
 
Regards,
Harsh Nathani
 
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!

Thank you @harshnathani , but this is not the result I'm expecting, the measure should sum all the values of the OP only if at least one are in LT, kind of first get rid of the list all the OP's that doesn't have at least one value with EE = LT, after that, sum all Lbs of each OP of this new list whatever the EE is. (i would like to graphic the EE values of every OP in a stacked column chart)

here i did a little example of the steps: 

Captura.PNG

Thank you again for your help.

Hi @Midguel ,

 

Please try the below measure:

 

CALCULATE (
   [Total LBS],
    FILTER (
        SUMMARIZE (
           'Data Base',
            'Data Base'[OP],
            'Data Base'[EE],
            "OP1",
            IF (
                'Data Base'[EE]
                 =
                    "LT",
                    1,
                    0
            )
        ),
       [OP1]
         =
            1
    )
)

 

123.JPG

 

Regards,

Harsh Nathani

 

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!

Hi @Midguel ,

 

Try this measure:

 

Measure = CALCULATE(SUM('Table'[Lbs]); SELECTCOLUMNS(CALCULATETABLE('Table'; 'Table'[EE] = "LT"); "OP"; 'Table'[OP]))
 

If you consider it as a solution, please mark as a solution and kudos.

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



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.

Top Solution Authors