Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Bonjour,
Je ne suis pas tres familière avec power query mais je souhaite savoir s’il est possible de faire la chose suivante :
J’ai un tableau qui regroupe des montants sur une période auxquels correspondent des clés comptables. Dans mon tableau il y a donc plusieurs fois la même clé. Je souhaite agréger les montants par clé, non pas pour en connaître le résultat mais pour en évaluer le signe et ensuite attribuer un code à chaque montant en fonction du signe des montants agrégés par clé.
Sur Excel ma formule pour la ligne 1 est :
SI(SOMME.SI.ENS.(A:A;B:B;B1)>0;C1;D1)
Merci
Myriam
Solved! Go to Solution.
Bonjour, @myriam_ouan , tu peux l'atteindre par la procédure comme ça
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MFCK1YlWMgKydU0RbEMkthFUDUi9LkwCxDEyVYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [KEY = _t, AMOUNT = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"AMOUNT", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom",
each
[
sum = List.Sum(Table.Group(#"Changed Type", {"KEY"}, {{"All", each _}}){[KEY=[KEY]]}[All][AMOUNT]),
test = if sum>0 then [C1="c"] else [C2="b"]
][test]
),
#"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"C1", "C2"}, {"C1", "C2"})
in
#"Expanded Custom"mais, je suis pas sûr si on doit changer des fonctions en version fraincaise (e.g. if => si) car j'utilisais tourjours Power Query en version anglaise.
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi @myriam_ouan
Can you supply an image of your data and expected results? I'm not clear what you mean by sign - it might be something confused in the French to English Google translation.
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Proud to be a Super User!
Hi Phil, thanks for your interest in my problem.
basically I want to determine wether the sum by accounting key of my numbers is positive or negative in order to assign it a code.
Here's a simplified example :
KEY AMOUNT C1 C2
1 100 a b
2 -50 c d
2 150 c d
2 200 c d
1 -150 a b
1 25 a b
If the sum of each amount corresponding to a key is positive it will be assigned the corresponding value in the column C1. If negative, C2. So with the example above, the sum for key 1 is negative so each amount will be assigned the code "b". For key 2 the sum is positive so each amount will be assigned the code "c".
As you will notice, some numbers will be given the negative associated code despite being positive and vice versa.
I hope this gives a better insight of my problem.
Thanks
Myriam
Bonjour, @myriam_ouan , tu peux l'atteindre par la procédure comme ça
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0MFCK1YlWMgKydU0RbEMkthFUDUi9LkwCxDEyVYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [KEY = _t, AMOUNT = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"AMOUNT", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom",
each
[
sum = List.Sum(Table.Group(#"Changed Type", {"KEY"}, {{"All", each _}}){[KEY=[KEY]]}[All][AMOUNT]),
test = if sum>0 then [C1="c"] else [C2="b"]
][test]
),
#"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"C1", "C2"}, {"C1", "C2"})
in
#"Expanded Custom"mais, je suis pas sûr si on doit changer des fonctions en version fraincaise (e.g. if => si) car j'utilisais tourjours Power Query en version anglaise.
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Bonjour @CNENFRNL , Je dois regrouper plusieurs lignes pour n'en faire qu'une et pour ne pas perdre mes données, je dois calculer toutes les colunes qui contiennent de valeurs. J'arrive à effectuer cette opération sur Excel en utilisant Somme.si.ens. ... C'est trop compliqué lol
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.