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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Ilka719
Frequent Visitor

How to compare values in same column?

How could I compare is there are same value in different groups in same table?
Trying this code:

Same =

var KP = CALCULATE(VALUES(Table[Key]),FILTER(Table,Table[Group]="Apple"))

var KA = CALCULATE(VALUES(Table[Key]),FILTER(Table,Table[Group]="Orange"))

return

if(KP=KA,"same","no")

But detects error: A circular dependency was detected

Ilka719_0-1697632727348.png

 

1 ACCEPTED SOLUTION

I would create a summary table that contains the group to lessen the number of rows to be scanned  and key then create a calculatead column to count whether the key has more than one distinct group. The summary table can either be created in DAX  or M. Please see attached sample.

 

Summary calc table

SummaryTable =
SUMMARIZE ( 'DataTable', 'DataTable'[Group], 'DataTable'[Key] )

calc column in SummaryTable

same_no = 
IF (
    CALCULATE (
        DISTINCTCOUNT ( SummaryTable[Group] ),
        ALLEXCEPT ( SummaryTable, SummaryTable[Key] )
    ) > 1,
    "same",
    "no"
)

You can then use this table to relate to the original table or as a reference in LOOKUPVALUE. Please see attached sample pbix. https://1drv.ms/f/s!AqxKG9R1145fiHWd4q_vHpM9NRlt?e=669nxs 





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.

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

Hi @Ilka719 ,

 

If you're trying to determine if a particualr key in  apple exists in orange as well, try this:

=
IF (
    (
        CALCULATE (
            DISTINCTCOUNT ( 'table'[key] ),
            FILTER (
                'table',
                'table'[key] = EARLIER ( 'table'[key] )
                    && 'table'[group] = "Apple"
            )
        )
            + CALCULATE (
                DISTINCTCOUNT ( 'table'[key] ),
                FILTER (
                    'table',
                    'table'[key] = EARLIER ( 'table'[key] )
                        && 'table'[group] = "Orange"
                )
            )
    ) > 1,
    "same",
    "no"
)




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.

Hi! 🙂
Tried, but the result is endless: 

Ilka719_0-1697659897895.png

😞

 

@Ilka719 

 

I'm assuming you have a very large table. One more fact that should be mentioned when asking for help. Or  possibly, there are other calculations that are slowing this down.

 





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.

I would create a summary table that contains the group to lessen the number of rows to be scanned  and key then create a calculatead column to count whether the key has more than one distinct group. The summary table can either be created in DAX  or M. Please see attached sample.

 

Summary calc table

SummaryTable =
SUMMARIZE ( 'DataTable', 'DataTable'[Group], 'DataTable'[Key] )

calc column in SummaryTable

same_no = 
IF (
    CALCULATE (
        DISTINCTCOUNT ( SummaryTable[Group] ),
        ALLEXCEPT ( SummaryTable, SummaryTable[Key] )
    ) > 1,
    "same",
    "no"
)

You can then use this table to relate to the original table or as a reference in LOOKUPVALUE. Please see attached sample pbix. https://1drv.ms/f/s!AqxKG9R1145fiHWd4q_vHpM9NRlt?e=669nxs 





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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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