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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.