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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
wsMac78AZ
Frequent Visitor

Filter Rows Identical Content Across Columns

Hope someone is able to help me.

 

I have a table below. I want to identify rows that have identical text across the 4 columns.

 

 BreakfastLunchDinnerSupper
MondayCerealSteakSoupBiscuit
TuesdaySoupSoupSoupSoup
WednesdayCerealSpaghettiSpaghettiSoup
ThursdaySoupSteakCurryCake
FridayCakeCakeCakeCake
SaturdayPorridgePorridgeSoupSpaghetti
SundaySoupSpaghettiSteakSoup

 

I would like to display the result in a table as below:

 

TuesdaySoupSoupSoupSoup
FridayCakeCakeCake

Cake

 

Also, I hope to print it into the card as below:

 

2
Same food

 

Would appreciate any help in this regard. Thanks!

 

 

1 ACCEPTED SOLUTION
johncolley
Solution Sage
Solution Sage

 

Hi @wsMac78AZ ,

 

You can create a calculated column such as:

Same Food = IF( 
Meals[Breakfast] = Meals[Lunch] && Meals[Breakfast] = Meals[Dinner] && Meals[Breakfast] = Meals[Supper], 1, 0)
You can insert the column as a basic filter as per picture to limit the table and put the column on a card.
johncolley_0-1654645054836.png

 

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

Simple enough,

PQ solution,

CNENFRNL_0-1654657623975.png

 

DAX solution,

CNENFRNL_1-1654657771989.png

 

For fun only, showcase of powerful Excel worksheet formula,

CNENFRNL_2-1654657848397.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
johncolley
Solution Sage
Solution Sage

 

Hi @wsMac78AZ ,

 

You can create a calculated column such as:

Same Food = IF( 
Meals[Breakfast] = Meals[Lunch] && Meals[Breakfast] = Meals[Dinner] && Meals[Breakfast] = Meals[Supper], 1, 0)
You can insert the column as a basic filter as per picture to limit the table and put the column on a card.
johncolley_0-1654645054836.png

 

Many thanks, John! Your approach is very simple and neat; I like it.

Well, this is a much simpler solution 🙂





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @wsMac78AZ ,

 

There are many ways to do this but most of these approaches involve Power Query.

 

Approach1 - Power Query only using the sample M Script below

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZDBCoMwEET/Zc9+RQVvhYKCh5DDUhcNlkTW7KF/3yQmVsXTDMmbyRCl4OnsgF+ooCYm/ATTesI5qpMlyMOsbzEedKWgE1o3Ol/eSOR6Gmwh/70LjhN5b66+pLpJ+FKfp9TCnLpwpoQ2bHJ7PLmViLXohTfw5ThkRjrb8s4+J6XEnlccxx4/R+sf", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Day = _t, Breakfast = _t, Lunch = _t, Dinner = _t, Supper = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Day", type text}, {"Breakfast", type text}, {"Lunch", type text}, {"Dinner", type text}, {"Supper", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Day"}, {{"Grouped", each _, type table [Day=nullable text, Breakfast=nullable text, Lunch=nullable text, Dinner=nullable text, Supper=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Unpivoted", each Table.UnpivotOtherColumns([Grouped], {"Day"}, "Attribute", "Value"), type table),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Grouped2", each Table.Group([Unpivoted], {"Day", "Value"}, {{"Count", each Table.RowCount(_), Int64.Type}}), type table),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Grouped2_Filtered", each Table.SelectRows([Grouped2], each [Count] = 4), type table),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Unpivoted", "Grouped2"}),
    #"Expanded Grouped" = Table.ExpandTableColumn(#"Removed Columns", "Grouped", {"Breakfast", "Lunch", "Dinner", "Supper"}, {"Breakfast", "Lunch", "Dinner", "Supper"}),
    #"Expanded Grouped2_Filtered" = Table.ExpandTableColumn(#"Expanded Grouped", "Grouped2_Filtered", {"Count"}, {"Count"}),
    #"Added Custom3" = Table.AddColumn(#"Expanded Grouped2_Filtered", "All True", each if [Count] = 4 then true else false, type logical),
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom3",{"Count"})
in
    #"Removed Columns1"

 Result  - you can use All True column to filter only those with identical texts.

danextian_0-1654644086503.png

 

Approach2 - Keep the original table, make a duplicate and unpivot and grouped the duplicate in PQ, create a calculated column in DAX. Please see sample pbix for the details.

danextian_1-1654644465512.png

 

You can then use the generated columns in DAX/PQ to create your card with a formula similar to below.

Same Food = 
CALCULATE ( COUNTROWS ( TablePQOnly ), TablePQOnly[All True] = TRUE () )

danextian_2-1654644640630.png

 

PBIX - https://drive.google.com/file/d/1VDFLIOpShuC3TjJEQkqBclwBPL0ydQov/view?usp=sharing 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.