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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
scharern
Frequent Visitor

Capture Date of Status Change for Product

I have a table of data that captures information about each product change over time. I need to determine which date Info1 changed. I've been trying to use EARLIER and a calculated column to flag each row as changed or unchanged but am struggling with how to group the EARLIER iteration by product. Here's a simplified example:

Product IDTransaction Index Transaction DateInfo1Info2 
Prod111/1/2017DomesticBlack
Prod121/6/2017DomesticBlack
Prod132/3/2017DomesticBlack
Prod142/4/2017ImportBlack
Prod154/5/2017ImportBlack
Prod2 11/6/2017DomesticSilver
Prod2 21/9/2017ImportSilver
Prod2 31/18/2017ImportSilver
Prod2 42/9/2017ImportSilver
Prod2 53/10/2017ImportSilver
Prod2 63/11/2017ImportSilver
Prod311/12/2017DomesticYellow
Prod321/13/2017DomesticYellow
Prod331/14/2017DomesticYellow
Prod341/15/2017DomesticYellow
Prod352/16/2017DomesticYellow
Prod362/17/2017DomesticYellow
Prod373/8/2017DomesticYellow
Prod383/19/2017DomesticYellow
Prod394/20/2017ImportYellow

 


 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @scharern 

From your example I undertand that you want not just change, but change only from domestic to import.If so create a new calc column in your table

 

Flag =
VAR Previous_ =
    CALCULATE (
        DISTINCT ( Table1[Info1] ),
        Table1[Index] = ( EARLIER ( Table1[Index] ) - 1 ),
        ALLEXCEPT ( Table1, Table1[Product] )
    )
RETURN
    IF ( Table1[Info1] <> Previous_, "Change" )

 

Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

Cheers  Datanaut

View solution in original post

7 REPLIES 7
Girish-Patil
Frequent Visitor

insted of change i want to show info 2 how should ido that??

 

AlB
Super User
Super User

Hi @jcbutts 

You probably need to modify only the data types in your columns. Make sure index is an integer and not text.  See it all at work in the attached file.

Flag = 
VAR Previous_ =
    CALCULATE (
        DISTINCT ( Table1[Transaction Date] ),
        Table1[Index] = ( EARLIER ( Table1[Index] ) - 1 ),
        ALLEXCEPT ( Table1, Table1[Product] )
    )
RETURN
    IF ( Table1[Transaction Date] <> Previous_ && NOT ISBLANK(Previous_), "Change" )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

That worked!  Thank you so much!

jcbutts
Helper I
Helper I

Hi AIB,

 

I tried something similar with the data below to try and flag when the date/time changes.  However, I get an error saying that DAX can't compare text and numbers and I should consider VALUE or FORMAT to change one of the two.  How would I modify that code for a date change vs a text change?

Product  Index  Transaction Date

Prod1   1 1/1/2017

Prod1   2 1/1/2017

Prod1   3 2/3/2017

Prod1   4 2/3/2017

Prod1   5 2/5/2017

Prod2   1 1/6/2017

Prod2   2 1/6/2017

Prod2   3 1/6/2017

Prod2   4 1/6/2017

Prod2   5 1/6/2017

Prod2   6 1/6/2017

Prod3  1  1/12/2017

Prod3  2  1/13/2017

Prod3  3 1/13/2017

Prod3  4 1/13/2017

Prod3  5 1/13/2017

Prod3  6 1/13/2017

Prod3  7 1/13/2017

Prod3  8 1/13/2017

Prod3  9 1/13/2017

 

AlB
Super User
Super User

Hi @scharern 

From your example I undertand that you want not just change, but change only from domestic to import.If so create a new calc column in your table

 

Flag =
VAR Previous_ =
    CALCULATE (
        DISTINCT ( Table1[Info1] ),
        Table1[Index] = ( EARLIER ( Table1[Index] ) - 1 ),
        ALLEXCEPT ( Table1, Table1[Product] )
    )
RETURN
    IF ( Table1[Info1] <> Previous_, "Change" )

 

Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

Cheers  Datanaut

insted of change i want to show info2 how should i do that??

scharern
Frequent Visitor

Excellent, thank you for your help @AlB 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors