Forum Discussion

AaronO23's avatar
AaronO23
Frequent Visitor
2 years ago
Solved

Creating a variance column within datatable to compare movement in value between dates

Hello,   I am trying to create a calculated column to show the change in a value between dates. The following is a simplified sample data for what I am working with:   Month Pers.No Full Nam...
  • Anonymous's avatar
    Anonymous
    2 years ago

    HI,AaronO23 


    Regarding the issue you raised, my solution is as follows:

     

    Depending on your needs, I suggest that if there is a problem with the data itself, directly modifying the data source is the most direct and effective approach. This ensures the accuracy and consistency of the data and avoids errors in reporting or analysis. Using DAX, while it is possible to adjust data through calculations, is used more for data analysis and generating insights than for data cleaning or data correction. This facilitates long-term data management and maintenance.

     

    Of course, if you have a new column indicating the current employee status, here is my solution:

    1.First I have created the following table and the column names and data are the data you have given:

    2. Below are the calculation column  I've created for your needs:

    FLAG = 
    VAR USERN='Table (2)'[Full Name]
    VAR CUREM=MONTH('Table (2)'[Month])
    VAR FSTATUE=
    CALCULATE(MAX('Table (2)'[statue]),FILTER('Table (2)','Table (2)'[Full Name]=USERN&&'Table (2)'[statue]="F"))
    RETURN IF(FSTATUE="F"&&'Table (2)'[statue]<>"F",1,0)
    

    3.Create a new table:

    Table 2 = FILTER('Table (2)','Table (2)'[FLAG]=0)

    4.Here's my final result, which I hope meets your requirements.

    Then use the latest table and use the method in my last post to meet your needs.

     

    Please find the attached pbix relevant to the case.

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.