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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
MStaford
New Member

Text Comparision from multiple rows in the same column

Hi Everyone,

 

Thankyou in advance for pardoning me for asking this questions and helping me with the solution.

 

Situation - I am working on a solution to idenfity the change in text between two entries of description added in two different dates for the same product name/ID.

These product ID and names are not in sequence and the dates could be three to six months apart. Also, the discriptions can vary from a single sentence to a para. The defference needs to be calculated between the latest two dates however, if needed, the solution should expand to all the dates.

I would prefer to apply this solution as a conditional format in a matrix table using ProductID's in Row, Date in Column and Description (First) as the value.

Here is the visual

 

Product-IDDateDescriptions
abc-12301/2/2024bla bla bal b
abc-12301/6/2024bla bla bal bl
abc-12301/12/2024bla bla bal bla
xyz-62601/2/2024yaba daba d
xyz-62601/6/2024yaba daba do
xyz-62601/12/2024yaba daba doo

 

I have tried to work with few solution but they are not giving great outcome plus i consider myself novice so not good at creating measures.

 

here is on measure i worked on
TxtDiff =

VAR CurrentItem = SELECTEDVALUE (sample-table'[Product-ID])

VAR CurrentDate = SELECTEDVALUE (sample-table'[Date])

 

var PrevText = CALCULATE (

MAX(sample-table'[Description]),

FILTER('sample-table', sample-table'[Product-ID] = CurrentItem && sample-table'[Date] < CurrentDate)
)
VAR CurrentText =SELECTEDVALUE (sample-table'[Description])

Return

IF(NOT(ISBLANK(PrevText)) && PrevText <>CurrentText,
"text are different",
"texts are the same"
)

the outcome is always coming up as "texts are the same" 😣

 

Thankyou in advance for your support 😊

2 ACCEPTED SOLUTIONS
SamWiseOwl
Super User
Super User

Hi @MStaford 

Your max is returning the biggest text NOT the last text by date.

I've used top to return the relative last date for the current date.

So each date is comparing to the one before etc

SamWiseOwl_0-1736332042855.png

 

 

Colour TxtDiff = 

VAR CurrentItem = SELECTEDVALUE('sample-table'[Product-ID])

VAR CurrentDate = SELECTEDVALUE ('sample-table'[Date])

VAR CurrentText =SELECTEDVALUE ('sample-table'[Descriptions])


var PrevText = CALCULATE (
maxx(
TOPN( 1,
        FILTER(all('sample-table'), 'sample-table'[Product-ID] = CurrentItem && 'sample-table'[Date] < CurrentDate),'sample-table'[Date],DESC)
,'sample-table'[Descriptions]
))

var final =
IF(NOT(ISBLANK(PrevText)) && PrevText <> CurrentText,
"#FF000050",
"#FFFFFF"
)

RETURN final

 


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

v-zhengdxu-msft
Community Support
Community Support

Hi @MStaford 

 

Please try this measure:

TxtDiff =
VAR _currentDate =
    MAX ( 'Table'[Date] )
VAR _currentPD =
    SELECTEDVALUE ( 'Table'[Product-ID] )
VAR _previousdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Date] < _currentDate
                && 'Table'[Product-ID] = _currentPD
        )
    )
VAR _previousDescription =
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Descriptions] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Product-ID] = _currentPD
                && 'Table'[Date] = _previousdate
        )
    )
RETURN
    IF (
        NOT ISBLANK ( _previousDescription )
            && _previousDescription <> SELECTEDVALUE ( 'Table'[Descriptions] ),
        "text are different",
        "texts are the same"
    )

The result is as follow:

vzhengdxumsft_0-1736387359907.png

 

Best Regards

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

View solution in original post

3 REPLIES 3
MStaford
New Member

Hi @SamWiseOwl and @v-zhengdxu-msft,
Thankyou for your posts and solutions. Please accept my apologies for delay in responding.
In desperation, I came across another solution which worked perfectly and I have applied it to my report.
I greatly appreciate your support and will be taking in the learnings from your suggessions.
Much appreciated your support and paitence.
Cheers

v-zhengdxu-msft
Community Support
Community Support

Hi @MStaford 

 

Please try this measure:

TxtDiff =
VAR _currentDate =
    MAX ( 'Table'[Date] )
VAR _currentPD =
    SELECTEDVALUE ( 'Table'[Product-ID] )
VAR _previousdate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Date] < _currentDate
                && 'Table'[Product-ID] = _currentPD
        )
    )
VAR _previousDescription =
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Descriptions] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Product-ID] = _currentPD
                && 'Table'[Date] = _previousdate
        )
    )
RETURN
    IF (
        NOT ISBLANK ( _previousDescription )
            && _previousDescription <> SELECTEDVALUE ( 'Table'[Descriptions] ),
        "text are different",
        "texts are the same"
    )

The result is as follow:

vzhengdxumsft_0-1736387359907.png

 

Best Regards

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

SamWiseOwl
Super User
Super User

Hi @MStaford 

Your max is returning the biggest text NOT the last text by date.

I've used top to return the relative last date for the current date.

So each date is comparing to the one before etc

SamWiseOwl_0-1736332042855.png

 

 

Colour TxtDiff = 

VAR CurrentItem = SELECTEDVALUE('sample-table'[Product-ID])

VAR CurrentDate = SELECTEDVALUE ('sample-table'[Date])

VAR CurrentText =SELECTEDVALUE ('sample-table'[Descriptions])


var PrevText = CALCULATE (
maxx(
TOPN( 1,
        FILTER(all('sample-table'), 'sample-table'[Product-ID] = CurrentItem && 'sample-table'[Date] < CurrentDate),'sample-table'[Date],DESC)
,'sample-table'[Descriptions]
))

var final =
IF(NOT(ISBLANK(PrevText)) && PrevText <> CurrentText,
"#FF000050",
"#FFFFFF"
)

RETURN final

 


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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