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

Sumar.si entre dos columnas

Estimados, necesito por favor vuestra ayuda para encontrar alguna fórmula que me permita sumar datos de una columna pero según los criterios de otra. La condición es que sume solo si encuentra que el dato es único en la columna criterio.

Dato 1Criterio
1045001201
1045001201
2045001202
3045001203
4045001204
100 

 

Debe sumar solo una vez los datos de las primeras dos filas dado que en la columna criterio se repite un valor dos veces, por tanto debe considerar una sola vez.

 

Espero haberlo explicado bien y que me puedan ayudar.

Gracias!

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@JDU 

 

Try this:

1) Calculate the average of your "Criterio":

Average = AVERAGE(Criterio[Dato 1])

2) Use SUMX with DISTINCT to sum these average values

Suma sin duplicados = SUMX(DISTINCT(Criterio[Criterio]); [Average])

To get this result:

result.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

9 REPLIES 9
v-lionel-msft
Community Support
Community Support

Hi @JDU ,

Maybe you can try this:

Column = 
VAR x = 
CALCULATE(
    COUNT([Criterio]),
    ALLEXCEPT(
        table,
        [Dato 1]
    )
)
RETURN
IF(
    x = 1,
    ADDCOLUMNS( )

)

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

An error appears with the expression "ADDCOLUMNS".
Please don't forget that what I need is to add up the data in the "Dato 1" column if the values in the "Criterio" column are different.

 

 

Anyway, thank you very much for your help!

 

az38
Community Champion
Community Champion

Hi @JDU 

try to create a new table 

Table2 = DISTINCT('Table')

It will remove duplicates

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

but, how do I relate the data from the new table to the table I need to add?

az38
Community Champion
Community Champion

@JDU 

just use in visual a new table instead of old with repeated values

 

do not hesitate to give a kudo to useful posts and mark solutions as solution


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

What I need to do is add up the values in one column if the values in another column are unique. When I create a new table with unique values I can't relate it to the original table.

I probably don't know how to do it.

PaulDBrown
Community Champion
Community Champion

@JDU 

 

Try this:

1) Calculate the average of your "Criterio":

Average = AVERAGE(Criterio[Dato 1])

2) Use SUMX with DISTINCT to sum these average values

Suma sin duplicados = SUMX(DISTINCT(Criterio[Criterio]); [Average])

To get this result:

result.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






The solution looks good, it's just what I need but I can't execute it. Consultations:

1) The average I create as a new column ... I do not get the same results as you.
2) SUMX I use it as a new measure?

Thanks for your help!

PaulDBrown
Community Champion
Community Champion

@JDU 

They are 2 seperate measures (no new columns).. 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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.