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
Anonymous
Not applicable

Comparing two table columns which is having Many to many relationship

 i have a two table in power bi .  Both tables have a  columntype as a common value. its a Many to many relationship.

 

THENNA_41_0-1639740309064.png

my dataset looks like  below 

 

Out_DataComparison_Totals   Table 

 

ColumnType     IN_Tables      EO_IN_Tables       EO_Out_Tables     CalendarYear

Adjust               500                    400                     478                        2021

Adjust               1000                 1000                   1000                       2022

Demand            500                    1400                  478                        2021

Demand            2500                  2500                  2500                      2022

 

vw_IntegrationDataCheck   table

 

ColumnType          CalendarYear      CMN

Adjust                       2021                 300

Adjust                       2022                1000

Demand                   2021                  750

Demand                   2022                 2500

 

Next after relationship i have CMN value into  Out_DataComparison_Totals  tables. 
Now  Out_DataComparison_Totals  tables looks like .i want to create extra column for true or fale .

 

if  all values matched column  should return True . 
if  all  not values matched column  should return fales. 

 

ColumnType     IN_Tables      EO_IN_Tables       EO_Out_Tables     CalendarYear     CMN     Status

Adjust               500                    400                     478                        2021              478         False 

Adjust               1000                 1000                   1000                       2022             1000        True 

Demand            500                    1400                  478                        2021              750         False 

Demand            2500                  2500                  2500                      2022              2500       True 

 

i have created below measure 

 

Check = IF(Out_DataComparison_Totals[IN_Tables]=Out_DataComparison_Totals[EO_IN_Tables]&&Out_DataComparison_Totals[EO_IN_Tables]=Out_DataComparison_Totals[EO_Out_Tables]&&Out_DataComparison_Totals[EO_Out_Tables]=RELATED(vw_IntegrationDataCheck[CMN]),"True","False")
 
But getting following warning Error 
 
The column 'vw_IntegrationDataCheck[CMN]' either doesn't exist or doesn't have a relationship to any table available in the current context.
 
any idea . how to resolve this warning Error .  thanks in advance. 
1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Anonymous  you can write 2 measures like this

CMN =
CALCULATE (
    MAX ( vw_IntegrationDataCheck[CMN] ),
    TREATAS (
        SUMMARIZE (
            Out_DataComparison_Totals,
            Out_DataComparison_Totals[ColumnType],
            Out_DataComparison_Totals[CalendarYear]
        ),
        vw_IntegrationDataCheck[ColumnType],
        vw_IntegrationDataCheck[CalendarYear]
    )
)


STATUS =
VAR _others =
    AVERAGEX (
        UNION (
            { MAX ( Out_DataComparison_Totals[EO_IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[EO_Out_Tables] ) }
        ),
        [Value]
    )
RETURN
    IF ( [CMN] = _others, TRUE (), FALSE () )

 

or a combined measure like this

Combined =
VAR _cmn =
    CALCULATE (
        MAX ( vw_IntegrationDataCheck[CMN] ),
        TREATAS (
            SUMMARIZE (
                Out_DataComparison_Totals,
                Out_DataComparison_Totals[ColumnType],
                Out_DataComparison_Totals[CalendarYear]
            ),
            vw_IntegrationDataCheck[ColumnType],
            vw_IntegrationDataCheck[CalendarYear]
        )
    )
VAR _others =
    AVERAGEX (
        UNION (
            { MAX ( Out_DataComparison_Totals[EO_IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[EO_Out_Tables] ) }
        ),
        [Value]
    )
RETURN
    IF ( _cmn = _others, TRUE (), FALSE () )

 

The pbix is atatched

smpa01_0-1639749975229.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

6 REPLIES 6
smpa01
Super User
Super User

@Anonymous  you can write 2 measures like this

CMN =
CALCULATE (
    MAX ( vw_IntegrationDataCheck[CMN] ),
    TREATAS (
        SUMMARIZE (
            Out_DataComparison_Totals,
            Out_DataComparison_Totals[ColumnType],
            Out_DataComparison_Totals[CalendarYear]
        ),
        vw_IntegrationDataCheck[ColumnType],
        vw_IntegrationDataCheck[CalendarYear]
    )
)


STATUS =
VAR _others =
    AVERAGEX (
        UNION (
            { MAX ( Out_DataComparison_Totals[EO_IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[EO_Out_Tables] ) }
        ),
        [Value]
    )
RETURN
    IF ( [CMN] = _others, TRUE (), FALSE () )

 

or a combined measure like this

Combined =
VAR _cmn =
    CALCULATE (
        MAX ( vw_IntegrationDataCheck[CMN] ),
        TREATAS (
            SUMMARIZE (
                Out_DataComparison_Totals,
                Out_DataComparison_Totals[ColumnType],
                Out_DataComparison_Totals[CalendarYear]
            ),
            vw_IntegrationDataCheck[ColumnType],
            vw_IntegrationDataCheck[CalendarYear]
        )
    )
VAR _others =
    AVERAGEX (
        UNION (
            { MAX ( Out_DataComparison_Totals[EO_IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[IN_Tables] ) },
            { MAX ( Out_DataComparison_Totals[EO_Out_Tables] ) }
        ),
        [Value]
    )
RETURN
    IF ( _cmn = _others, TRUE (), FALSE () )

 

The pbix is atatched

smpa01_0-1639749975229.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@Anonymous  did you have a chance to look into it?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

@smpa01   thank you for you reply .let me check  will update you . 

Anonymous
Not applicable

@smpa01  Values repated multiple time . i have tired your measure sir 

@Anonymous  yes that's right mate which is why you need an index column like this

 

smpa01_0-1640009755830.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
VahidDM
Super User
Super User

@Anonymous 

 

It seems this post is same as your previous post, I shared a solution in the previous one, please check and let me know if that does not help.

 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Comparing-two-table-columns-which-is-having-Many-to-many/m-p/2244609#M53826

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

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.