Forum Discussion

Hamdan1234's avatar
Hamdan1234
Helper III
4 years ago
Solved

DAX Formula

I had this below table. 

CourseABC1ABC2ABC3
Duration36 Months24 Months18 Months
Asst ManagerYNY
ADYNY
CEONYN
COONNY
ManagerYYN

to which after transposing I converted to below

Job PostCoursesDurationCompletion
Asst ManagerABC136 MonthsY
ADABC136 MonthsY
CEOABC136 MonthsN
COOABC136 MonthsN
ManagerABC136 MonthsY
Asst ManagerABC224 MonthsN
ADABC224 MonthsN
CEOABC224 MonthsY
COOABC224 MonthsN
ManagerABC224 MonthsY
Asst ManagerABC318 MonthsY
ADABC318 MonthsY
CEOABC318 MonthsN
COOABC318 MonthsY
ManagerABC318 MonthsN

I then merged it with another table my table loooks like this now

Job PostCoursesDurationCompletionCompletion Date
Asst ManagerABC136 MonthsY12/02/2015
ADABC136 MonthsY18/02/2018
CEOABC136 MonthsN17/08/2020
COOABC136 MonthsN09/10/2012
ManagerABC136 MonthsY12/02/2017
Asst ManagerABC224 MonthsN08/02/2019
ADABC224 MonthsN01/08/2020
CEOABC224 MonthsY09/01/2012
COOABC224 MonthsN12/02/2021
ManagerABC224 MonthsY02/02/2015
Asst ManagerABC318 MonthsY01/02/2018
ADABC318 MonthsY07/08/2020
CEOABC318 MonthsN09/10/2017
COOABC318 MonthsY12/02/2017
ManagerABC318 MonthsN08/02/2019

The data shows that each post has completed the courses and have dates with them showing when they completed. The duration of test shows how long will it be valid. So I want to have two columns or measures. One will show the date with respect to duration and date the compliance of each job. My outcome should look like below table.

Job PostCoursesDurationCompletionCompletion DateValid Date of TestTest take
Asst ManagerABC136 MonthsY12/02/201512/02/2018Non compliant
ADABC136 MonthsY18/02/201818/02/2021Non compliant
CEOABC136 MonthsN17/08/202017/08/2023Compliant
COOABC136 MonthsN09/10/201209/10/2015Non compliant
ManagerABC136 MonthsY12/02/201712/02/2020Non compliant
Asst ManagerABC224 MonthsN08/02/201908/02/2021Non compliant
ADABC224 MonthsN01/08/202001/08/2022Compliant
CEOABC224 MonthsY09/01/201209/01/2014Non compliant
COOABC224 MonthsN12/02/202112/02/2023Compliant
ManagerABC224 MonthsY02/02/201502/02/2017Non compliant
Asst ManagerABC318 MonthsY01/02/201801/02/2020Non compliant
ADABC318 MonthsY07/08/202007/08/2022Compliant
CEOABC318 MonthsN09/10/201709/10/2019Non compliant
COOABC318 MonthsY12/02/201712/02/2019Non compliant
ManagerABC318 MonthsN08/02/201908/02/2021Non compliant
  • Hamdan1234  you can use following two measures to achieve what you need after the very final merge

     

    ValidUntil = 
    VAR _0 = ADDCOLUMNS('Table',"ValidTill", 'Table'[Completion Date]+(CONVERT(LEFT('Table'[Duration],2),INTEGER)*DIVIDE(365,12)))
    RETURN MAXX(_0,[ValidTill])
    
    isValidNow = SWITCH(true(),[ValidUntil]<=TODAY(),"Non COmpliant","Compliant")

     

     

1 Reply

  • smpa01's avatar
    smpa01
    Community Champion

    Hamdan1234  you can use following two measures to achieve what you need after the very final merge

     

    ValidUntil = 
    VAR _0 = ADDCOLUMNS('Table',"ValidTill", 'Table'[Completion Date]+(CONVERT(LEFT('Table'[Duration],2),INTEGER)*DIVIDE(365,12)))
    RETURN MAXX(_0,[ValidTill])
    
    isValidNow = SWITCH(true(),[ValidUntil]<=TODAY(),"Non COmpliant","Compliant")