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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Return a Value of a column depends on the values from another table

I am trying to add another column that returns a value (either "Both", "with Design only" or "with As-Built only") from another source table that may contain more than 1 value.

 

Work OrderEstimate Type
C1509036072Design
P1510000938Design
C1511010088Design
C1510004452Design
C1511029159Design
C1509036829Design
C1511013021Design
C1509036072As-Built
C1510039895As-Built
C1511010088As-Built
C1510032088As-Built
C1511029159As-Built
C1511014036As-Built
C1511013021As-Built

 

the result should be:

Work OrderResult
C1509036072Both
P1510000938Design Only
C1510039895As-Built Only
C1511010088Both
C1510004452Design Only
C1510032088As-Built Only
C1511029159Both 
C1509036829Design Only
C1511014036As-Built Only
C1511013021Both
9 REPLIES 9
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Incase you need a measure

 

One or Both =
VAR _countdesign =
    COUNTX (
        FILTER (
            'Table',
            [Work Order]
                = MAX ( [Work Order] )
                && [Estimate Type] = "Design"
        ),
        [Work Order]
    ) + 0
VAR _countasbuilt =
    COUNTX (
        FILTER (
            'Table',
            [Work Order]
                = MAX ( [Work Order] )
                && [Estimate Type] = "As-Built"
        ),
        [Work Order]
    ) + 0
VAR _sum = _countdesign + _countasbuilt
RETURN
    SWITCH (
        TRUE (),
        _sum > 1, "Both",
        _countdesign >= 1
            && _countasbuilt = 0, "Design Only",
        "As-Built Only"
    )

 

1.jpg

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Anonymous
Not applicable

Thank you for the formula. I forgot to mention that in the table there will be multiple rows for every Work Order that consist of either design or as-built value because there is another field involve, for example:

 

Work OrderEstimate TypeCU
C1509036072As-BuiltLHW2-SDE
C1509036072As-BuiltSAS2-UA-XDE
C1509036072As-BuiltGUY2-MRK
C1509036072As-BuiltGUY2-TCL
C1509036072As-BuiltWIR2-G38
C1509036072As-BuiltCBL2-AT30
C1509036072As-BuiltCON2-W302

 

and the same goes for other Work orders. I don't know if the formula you've given is applicable for this one.

Thanks a lot!

Hi @Anonymous ,

 

The formula should work.

 

Else can you share sample data and the expected output.

 

Regards,

Harsh Nathani

Anonymous
Not applicable

Here's the sample data:

Work OrderEstimate TypeCU
C1711005413DESIGNGEN1-ET-RSC-MV
C1711005413DESIGNCON1-C-ABR
C1711005413DESIGNCON2-W3030
C1711005413DESIGNCON2-W3030A
C1711005413DESIGNGEN1-ELECTAPE-HV-B-V
C1711005413ASBUILTCBL2-AT30
C1711005413ASBUILTCON2-W302
C1711005413ASBUILTFST1-B16O150S
C1711005413ASBUILTGEN1-ELECTAPE-LV-B
C1711005413ASBUILTGRD2-INS-C1
C1711005413ASBUILTGUY2-ANC-1-18-OVL
C1507030290ASBUILTWIR2-T30-1INS
C1507030290ASBUILTPOL2-IC13505
C1507030290ASBUILTLHW2-SSTA
C1507030290ASBUILTINS3-B-PST-PP170E
C1507030290ASBUILTSAS2-UA-ANG
C1508002877DESIGNCON2-W3010
C1508002877DESIGNCON2-W302A
C1508002877DESIGNINS3-L-PDE-33B
C1508002877DESIGNSAS2-UA-XDE
C1508002877DESIGNTAG2-PLT-A
C1508002877DESIGNCND2-BA30

 

and this should be the result:

Work OrderResult
C1711005413Both
C1507030290ASBUILT Only
C1508002877DESIGN Only

HI @Anonymous ,

 

 

One or Both = 
var _countdesign = countx(filter('Table', [Work Order] = MAX([Work Order]) && [Estimate Type] = "DESIGN"),[Work Order])+0
var _countasbuilt = countx(filter('Table', [Work Order] = MAX([Work Order]) && [Estimate Type] = "ASBUILT"),[Work Order])+0
var _sum = _countdesign + _countasbuilt
return
switch ( true(),
_countdesign >=1 && _countasbuilt = 0 ,  "Design Only" ,

_countasbuilt >=1 && _countdesign = 0 ,  "ASBULIT Only" ,
"BOTH"
)

 

 

1.jpg

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

amitchandak
Super User
Super User

@Anonymous , Try as a new column

 

new column  = 
var _cntd = countx(filter(Table, [Work Order] =earlier([Work Order]) && [Estimate Type] = "Design"),[Work Order])+0
var _cntb = countx(filter(Table, [Work Order] =earlier([Work Order]) && [Estimate Type] = "As-Built"),[Work Order])+0
return
switch ( true(),
_cntd >=1 && _cntb>= 1, "Both",
_cntd >=1 && _cntb =0 ,  "Design Only" ,
"As-Built Only"
)
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you for the formula. I forgot to mention that in the table there will be multiple rows for every Work Order that consist of either design or as-built value because there is another field involve, for example:

 

Work OrderEstimate TypeCU
C1509036072As-BuiltLHW2-SDE
C1509036072As-BuiltSAS2-UA-XDE
C1509036072As-BuiltGUY2-MRK
C1509036072As-BuiltGUY2-TCL
C1509036072As-BuiltWIR2-G38
C1509036072As-BuiltCBL2-AT30
C1509036072As-BuiltCON2-W302

 

and the same goes for other Work orders. I don't know if the formula you've given is applicable for this one.

Thanks a lot!

@Anonymous , Try that and let me know issues.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@Anonymous - I'm thinking something like:

 

Estimate Type =
  VAR __Table = SUMMARIZE(RELATEDTABLE('OtherTable'),[Result])
RETURN
  IF(COUNTROWS(__Table)>1,"Both",MAXX(__Table,[Result]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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