Forum Discussion

OsmanBaba's avatar
OsmanBaba
New Member
2 years ago

Sum function not summing relatively

Hi,

 

I'm working on a dax function that conditions two columns and gives an output however one of my columns called hours doesn't seem to be Suming relatively when it's put in the calculated column.

 

Below is my DAx Measure

 

Color Code =
VAR LengthOfService = EssLeaveTimeOffDates[Months of Service]
VAR Hours = SUM(EssLeaveTimeOffDates[Hours])
VAR DebugInfo = " Hours: " & Hours
RETURN
    IF(
        LengthOfService >= 60,
        IF(
            Hours   >= 1464,
            "Red (" & DebugInfo & ")",
            IF(
                Hours   >= 732 && Hours < 1464,
                "Amber",
                "Default Color "  & DebugInfo & ")"
            )
        ),
        IF(
            LengthOfService >= 24 && LengthOfService < 60,
            IF(
                 Hours  >= 366 && Hours < 732,
                "Amber",
                IF(
                     Hours   >= 732,
                    "Red",
                    "Default Color"
                )
            ),
            IF(
                LengthOfService >= 6 && LengthOfService < 24,
                IF(
                     Hours  >= 188 && Hours < 376,
                    "Amber",
                    IF(
                         Hours  >= 376,
                        "Red",
                        "Default Color"
                    )
                ),
                IF(
                    LengthOfService < 6,
                    "Red",
                    "Default Color"
                )
            )
        )
    )
 
Here is the table as you can see I would need the hour value to be 1492 however it's summing all the hours and is 11863.63 I want it to sum relatively based on the row.
 

2 Replies

  • If anyone looking for the answer it was because i was trying to do it as a calculated column instead of a measure. Thank you

  • I want it to sum relatively based on the row.

    Not clear to me what you mean by that. Can you show the expected result based on your sample data?