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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
manojk_pbi
Helper V
Helper V

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 table or a new table with all necessary details to use it for reporting. 

 

Any suggestions are well appreciated. Thanks in advance

 

LessonLearned table contains 

LLID is unique key between both the tables.

LLIDMilestoneStatusUpdated
L1M102-Dec-2025
L2M202-Dec-2025
L3M502-Aug-2025
L4M502-Jun-2025
L5M5

02-Jul-2025

Lesson Learned Status table contains

LLIDCurrentStateLastUpdateDueDate
L3WIP02-Jan-202631-Jan-2026
L4WIP02-Dec-202502-Dec-2025
L5DONE02-Jul-202502-Jul-2025

Output expected used for visualization or automation 

for Milestone M4/M5 need to check the LLID present in status table, if present mark it as Yes.

OpenAgeing : Calculate the ageing using DueDate and CurrentState (=WIP)

LLIDMilestoneStatusUpdatedEntryInERPOpen Ageing
L1M102-Dec-2025  
L2M202-Dec-2025  
L3M502-Aug-2025Yes3 days
L4M502-Jun-2025Yes60 days
L5M502-Jul-2025Yes 
1 ACCEPTED SOLUTION
cengizhanarslan
Super User
Super User

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" )
_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

6 REPLIES 6
cengizhanarslan
Super User
Super User

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" )
_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Thanks for your reply. I am getting error when i add EntryInERP calculated column. I am not getting the table LessonLearned while setting the value to HasStatus.

Hi @manojk_pbi ,

Thanks for reaching out to the Microsoft fabric community forum. 

 

This error usually occurs due to a table name or column context mismatch. Please verify the exact name of the table in the Fields pane. If the table name contains spaces (for example, Lesson Learned instead of LessonLearned).

Additionally, please check whether a relationship exists between Lesson Learned and Lesson Learned Status on LLID. If the relationship is missing or inactive, the calculation may not work as expected.

If I misunderstand your needs or you still have problems on it, please feel free to let us know. 

Best Regards, 
Community Support Team  

I am getting below error when added as column. Pls advice me what is wrong here

manojk_pbi_0-1770194125361.png

 

Hi @manojk_pbi ,

Thanks for sharing the update

Everything is actually working as expected now. The reason you were seeing a value of 2 earlier is that the visual was automatically summing the column after multiple related rows from the Lesson Learned Status table were pulled in  LLID 1 has more than one related status, so the value 1 was counted more than once. After switching the field to Don’t summarize, the table correctly shows the result per lesson learned: 1 when at least one related status record exists, and 0 when it doesn’t.

Best regards,
Community Support Team

Thanks for your explanation and sample. Helps lot..

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.