Forum Discussion

manojk_pbi's avatar
manojk_pbi
Helper V
6 months ago
Solved

Write logic for Calculated Column or Measure

Hi,   I have 2 tables recording the details for lessonsLearned in the process and another one is record lessonlearned related activity.   I need to create a calculated column in lessonlearned tab...
  • cengizhanarslan's avatar
    6 months ago

    1) EntryInERP

    Create this calculated column in LessonLearned:

    EntryInERP =
    VAR HasStatus =
        CALCULATE (
            COUNTROWS ( 'Lesson Learned Status' ),
            'Lesson Learned Status'[LLID] = LessonLearned[LLID]
        ) > 0
    RETURN
    IF (
        LessonLearned[Milestone] IN { "M4", "M5" } && HasStatus,
        "Yes",
        BLANK ()
    )

     

    2) Open Ageing

    Open Ageing =
    VAR State =
        LOOKUPVALUE (
            'Lesson Learned Status'[CurrentState],
            'Lesson Learned Status'[LLID], LessonLearned[LLID]
        )
    VAR DueDate =
        LOOKUPVALUE (
            'Lesson Learned Status'[DueDate],
            'Lesson Learned Status'[LLID], LessonLearned[LLID]
        )
    VAR LastUpdate =
        LOOKUPVALUE (
            'Lesson Learned Status'[LastUpdate],
            'Lesson Learned Status'[LLID], LessonLearned[LLID]
        )
    VAR Days =
        IF ( State = "WIP" && NOT ISBLANK ( DueDate ) && NOT ISBLANK ( LastUpdate ),
            DATEDIFF ( LastUpdate, DueDate, DAY )
        )
    RETURN
    IF ( NOT ISBLANK ( Days ), Days & " days" )