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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
lafakios
Helper I
Helper I

Create a change log of dates

Hi,

 

I have a table similar to the below. 

The first objective is to add a flag that will indicate when the Ver value changes, as the 5th column illustrates below

 

ItemSWVerYYYY.MMChangeFlag
ServerASWA12020.01 
ServerASWA12020.02 
ServerASWA12020.03 
ServerASWA12020.04 
ServerASWA22020.051
ServerASWA22020.06 
ServerASWA22020.07 
ServerBSWB12020.01 
ServerBSWB12020.02 
ServerBSWB22020.031
ServerBSWB22020.04 
ServerBSWB22020.05 
ServerBSWB32020.061
ServerBSWB32020.07 
ServerCSWC12020.01 
ServerCSWC12020.02 
ServerCSWC12020.03 
ServerCSWC12020.04 
ServerCSWC12020.05 
ServerCSWC12020.06 
ServerCSWC12020.07 

 

The key objective is to create a calculated table of the below structure.

The table should have the change log per item including the pair of Ver and Change Date.

Ideally, even the very first occurence of a ver on an item should be flagged as change (1), so that the initial value will also be included in the change log, as below.

 

ItemSWVerChangeDate
ServerASWA12020.01
ServerASWA22020.05
ServerBSWB12020.01
ServerBSWB22020.03
ServerBSWB32020.06
ServerCSWC12020.01

 

Thanks in advance for your support.

 

Regards,

Akis

2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @lafakios,

 

Can you please try this approach:

 

1. Create the ChangeFlag

ChangeFlag = 
VAR CurrentItem = Table[Item]
VAR CurrentSW = Table[SW]
VAR CurrentVer = Table[Ver]
VAR PrevVer = 
    CALCULATE(
        MAX(Table[Ver]),
        FILTER(
            Table,
            Table[Item] = CurrentItem &&
            Table[SW] = CurrentSW &&
            Table[YYYY.MM] < EARLIER(Table[YYYY.MM])
        )
    )
RETURN
IF(ISBLANK(PrevVer) || PrevVer <> CurrentVer, 1, BLANK())

2. Create the Change Log Table

ChangeLog = 
FILTER(
    ADDCOLUMNS(
        Table,
        "ChangeDate", Table[YYYY.MM]
    ),
    NOT(ISBLANK(Table[ChangeFlag]))
)

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

ryan_mayu
Super User
Super User

@lafakios 

you can try this to creaet a column

Column =
var _date=CALCULATE(min('Table'[YYYY.MM]),ALLEXCEPT('Table','Table'[Item],'Table'[SW],'Table'[Ver]))
return if(_date='Table'[YYYY.MM],1)
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ryan_mayu
Super User
Super User

@lafakios 

you can try this to creaet a column

Column =
var _date=CALCULATE(min('Table'[YYYY.MM]),ALLEXCEPT('Table','Table'[Item],'Table'[SW],'Table'[Ver]))
return if(_date='Table'[YYYY.MM],1)
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks all to your kind advice and support!

I could manage to successfully build the ChangeLog table.

 

I created the ChangeFlag column by using the below code (from the second reply)

 

ChangeFlag =
        var _date CALCULATE(MIN('Table'[YYYY.MM]), ALLEXCEPT('Table','Table'[Item]'Table'[SW]'Table'[Ver]))
return 
        if(_date 'Table'[YYYY.MM]1, BLANK() )

 

And I created the ChangeLog table by using the below code (from the first reply)

 

ChangeLog = 
FILTER(
    ADDCOLUMNS(
        Table,
        "ChangeDate", Table[YYYY.MM]
    ),
    NOT(ISBLANK(Table[ChangeFlag]))
)

 

Once again, many thanks for your support.

Sahir_Maharaj
Super User
Super User

Hello @lafakios,

 

Can you please try this approach:

 

1. Create the ChangeFlag

ChangeFlag = 
VAR CurrentItem = Table[Item]
VAR CurrentSW = Table[SW]
VAR CurrentVer = Table[Ver]
VAR PrevVer = 
    CALCULATE(
        MAX(Table[Ver]),
        FILTER(
            Table,
            Table[Item] = CurrentItem &&
            Table[SW] = CurrentSW &&
            Table[YYYY.MM] < EARLIER(Table[YYYY.MM])
        )
    )
RETURN
IF(ISBLANK(PrevVer) || PrevVer <> CurrentVer, 1, BLANK())

2. Create the Change Log Table

ChangeLog = 
FILTER(
    ADDCOLUMNS(
        Table,
        "ChangeDate", Table[YYYY.MM]
    ),
    NOT(ISBLANK(Table[ChangeFlag]))
)

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hi,

 

Thanks for the reply and for the suggested DAX code!

 

It actually did generate the change flag in the expected way.

The created table looked also good.

 

When doing some sample check, I came across a few cases like the below

The ChangeFlag was set to 1 without having any change in the Ver attribute.

Would there be any way to further investigate these cases and prevent this from happening?

 

ItemSWVerYYYY.MMChangeFlag
ServerASWA12020.01 
ServerASWA12020.02 
ServerASWA12020.031
ServerASWA12020.041

 

 

Thanks in advance for your help and support.

 

Regards,

Akis

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors