Forum Discussion
wrong measure total including if statement
- Anonymous2 years ago
Hi Laura1996 ,
Based on the description, try to use the following DAX formula.
Faktor final = VAR IsSpecificUnit = SUMX( Komm, IF( Komm[Unit] IN {"M", "GA", "L", "KG"}, RELATED('Factor'[Factor]), Komm[Amount] * RELATED('Factor'[Factor]) ) ) RETURN IF ( HASONEVALUE(Komm[Name]), IsSpecificUnit, SUMX( Komm, IF ( Komm[Unit] IN {"M", "GA", "L", "KG"}, RELATED('Factor'[Factor]), Komm[Amount] * RELATED('Factor'[Factor]) ) ) )Then, select the Jack name.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Also I need to focus on this "collecting= "M" || collecting="GA" || collecting="L" || collecting="KG"
the measure shouldn't work with "ST", because there are many more units than just those mentioned up. So when I make an if statement, I have to define which to "exclude" rather than which to consider.
Wait, you said in your first post, Jack has value of 21 which is 6+15.
I thought 6 (2*3 because ST) and 15 (5*3 because ST), no?
What value for Jack, 9 or 21?
And when not selected, 6 (2*3 ST) + 15 (5*3 ST) + 6 (6*1 M) + 4 (4*1 KG) = 31
Also those M, GA, L, KG in if statement, as far as i can tell, this only for differentiate which will be multiplied and not. I only put ST for multiplying and you can add the rest.
- Laura19962 years ago
Helper I
Yes sorry, that was my mistake now because I didn't seen the number 15 in your table. 21 should be correct. Also 31 is correct, however its not working for my data, because my result is always 3709,60. And also in your code I can't add the other table for the Factor (Table "Factor").
Actually trying to add the rest is not working or at least I didn't still figure out how to make it work...- Irwan2 years ago
Super User
How do you collect value from another table?
If it is from a column in another table, you can try adding variable.
I can not test it right now but something like this : var _Factor = SELECTEDVALUE('Table 2'[Factor]).
Then use that variable to replace factor value from DAX above.
Thank you.