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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Sum IF power query

Formula that some the value of flagDia until the day in question. Ex .: until the 7th the value must be 5, 8th = 5, 9th = 5, 10th = 6.

 

Please, can anyone help me?

 

ex.: Sum( flagDay, Data <= data)

 

FABRICIOFERREIR_0-1601466289377.png

Formula that some the value of flagDia until the day in question. Ex .: until the 7th the value must be 5

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

hello @Anonymous 

 

check out this solution. Use Table.SelectRows to filter the table, then you reference the column and use the List.Sum-function to sum that column

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLVM7DUMzJQ0lEyUIrVAQpYoAtYwgUMwQLGBmgCBoZ6hgYoAkboAiboAqZwAYgtBmbIKmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, flagDay = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Date", Date.Type, "de-DE"}, {"flagDay", Int64.Type}}),
    AddSumTil30sept20 = List.Sum(Table.SelectRows(ChangedType, each [Date]<=#date(2020,9,30))[flagDay])
in
    AddSumTil30sept20

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

1 REPLY 1
Jimmy801
Community Champion
Community Champion

hello @Anonymous 

 

check out this solution. Use Table.SelectRows to filter the table, then you reference the column and use the List.Sum-function to sum that column

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLVM7DUMzJQ0lEyUIrVAQpYoAtYwgUMwQLGBmgCBoZ6hgYoAkboAiboAqZwAYgtBmbIKmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, flagDay = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Date", Date.Type, "de-DE"}, {"flagDay", Int64.Type}}),
    AddSumTil30sept20 = List.Sum(Table.SelectRows(ChangedType, each [Date]<=#date(2020,9,30))[flagDay])
in
    AddSumTil30sept20

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors