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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Compare 2 rows from the same table

Hi Team,

 

Need your assistance for the below query.

I have one table that is fetched in PowerBI as below

 

IDMessageIdEventtypeTimestampSystemTypeId
1101Pack14/02/18 00:00ABC
2102Unpack14/02/18 00:00ABC
3103Unpack14/02/18 01:00ABC
4104Pack14/02/18 01:00ABC
5105Unpack14/02/18 01:00ABC
6101Pack14/02/18 00:00XYZ
7102Unpack14/02/18 00:00XYZ
8104Pack14/02/18 01:00XYZ
9105Pack14/02/18 01:00XYZ

 

I want to compare the rows with the same MessageID.

For example: I am comparing MessageID 101, then all the values like Eventtype, Timestamp are matching for both the systems i.e. ABC and XYZ.

But for the MessageID 105 the value for Eventtype is not matching or both the systems i.e. ABC and XYZ hence this message will not be counted as a MATCH message.

 

Finally i want to show it on the dashboard as

 

14/02/18 00:00          14/02/18 01:00

Count of Messages         Count of Messages

ABC               XYZ          ABC                 XYZ

2                     2               3                     1

 

I require a flag across the above table that will help me to obtain the above result in PowerBI.

Can you please assist me with the same.

Thank you so much in advance.

 

 

1 REPLY 1
stretcharm
Memorable Member
Memorable Member

You can use Grouping and Pivoting in the Query editor

 

Here is an advanced query script using your sample data. Having the values on the same row means you can also Calculated the difference and filter for only non zero differences.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0AJEBicnZII6JvoGRvqGFgoGBlYEBUMDRyVkpVidayQisEkSG5hUQUGsMVmuMXa0hqloTsFoTbC5AU2kKVmlKlKlmBP0VERkFVmlOhL9gai0IuhWm0hLuVrwqYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, MessageId = _t, Eventtype = _t, Timestamp = _t, SystemTypeId = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"MessageId", Int64.Type}, {"Eventtype", type text}, {"Timestamp", type datetime}, {"SystemTypeId", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"SystemTypeId", "Timestamp"}, {{"Count", each Table.RowCount(_), type number}}),
    #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[SystemTypeId]), "SystemTypeId", "Count", List.Sum),
    #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Diff", each [ABC]-[XYZ]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Diff", Int64.Type}})
in
    #"Changed Type1"

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors