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
ManucruzGR
New Member

Consulta suma con filtros (?)

Hola! tengo que hacer una suma de las precipitaciones anuales de varias estaciones meteorológicas, para lo cual tengo una columna de precipitaciones (en mm) una de la fecha de dicha precipitacion (día, mes, año) y otra del ID de la Estacion meteorológica. Cómo hago para poder obtener cuanto llovio por año por estación? Estuve googleando pero no encontré nada que entendiera como para poder hacerlo.

Desde ya muchisimas gracias por cualquier ayuda o guía.

Saludos!

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @ManucruzGR 

You can put the following code in Advanced Editor in power query as a example:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7RCcAgDATQXfwWkpxJtbNI91+jaqk10p9w8LhwtYaSTUMMoJPAwi2qtJNLuOLURFIcG1YGwSt7HWXIPwsTvKt3kDpO9rDa8Q0vPcp4t+o7fDLYl+E0bbqV+7DrBg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [d_Estacion = _t, Fecha = _t, id_Campaña = _t, #"Precipitacion (mm)" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"d_Estacion", Int64.Type}, {"Fecha", type date}, {"id_Campaña", Int64.Type}, {"Precipitacion (mm)", Int64.Type}}),
    #"Extracted Year" = Table.TransformColumns(#"Changed Type",{{"Fecha", Date.Year, Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Extracted Year", {"d_Estacion", "Fecha"}, {{"Sum", each List.Sum([#"Precipitacion (mm)"]), type nullable number}})
in
    #"Grouped Rows"

vxinruzhumsft_0-1672196225931.png

Best Regards!

Yolo Zhu

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

 

View solution in original post

5 REPLIES 5
v-xinruzhu-msft
Community Support
Community Support

Hi @ManucruzGR 

You can put the following code in Advanced Editor in power query as a example:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc7RCcAgDATQXfwWkpxJtbNI91+jaqk10p9w8LhwtYaSTUMMoJPAwi2qtJNLuOLURFIcG1YGwSt7HWXIPwsTvKt3kDpO9rDa8Q0vPcp4t+o7fDLYl+E0bbqV+7DrBg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [d_Estacion = _t, Fecha = _t, id_Campaña = _t, #"Precipitacion (mm)" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"d_Estacion", Int64.Type}, {"Fecha", type date}, {"id_Campaña", Int64.Type}, {"Precipitacion (mm)", Int64.Type}}),
    #"Extracted Year" = Table.TransformColumns(#"Changed Type",{{"Fecha", Date.Year, Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Extracted Year", {"d_Estacion", "Fecha"}, {{"Sum", each List.Sum([#"Precipitacion (mm)"]), type nullable number}})
in
    #"Grouped Rows"

vxinruzhumsft_0-1672196225931.png

Best Regards!

Yolo Zhu

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

 

ManucruzGR
New Member

Hi, this is te table (a portion of it):

id_EstacionFechaid_CampañaPrecipitacion (mm)
875402/9/20104178
8754018/3/20104152
875402/2/20104150
8754018/2/20104150
8754028/10/20104140
8754012/4/20104135

 

and this is the output format:

Id_EstacionAñoPrecipitaciones (mm)
87542010588
87542011893
845620181236

Update the source step in the code below. 
Does this work?

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xc3BCQAxCETRXjwHHI0SU0uw/zaSva1ehIHH9xyK5QYahM1QVsg3TN5ZQTl+YLJEAa4VaC84OuiFCgSsFVgrGEt9MZ0yLw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id_Estacion = _t, Fecha = _t, id_Campaña = _t, #"Precipitacion (mm)" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id_Estacion", Int64.Type}, {"Fecha", type date}, {"id_Campaña", Int64.Type}, {"Precipitacion (mm)", Int64.Type}}),
#"Inserted Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([Fecha]), Int64.Type),
#"Grouped Rows" = Table.Group(#"Inserted Year", {"id_Estacion", "Year"}, {{"Rainfall (mm)", each List.Sum([#"Precipitacion (mm)"]), type nullable number}})
in
#"Grouped Rows"

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

@ManucruzGR  if this resolves the query please accept it as the solution so others can access it faster. Thanks ! 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash
adudani
Super User
Super User

can you post sample data / columns / pbix file for reference after removing sensitive data and also a sample output?

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

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