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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
sgintowt
Helper I
Helper I

New column with two conditions

Hello,

 

I want to add a new column to my data marked "yes" or "no".

I have "table 1" with all the data and I have a second "table 2" imported to the data model with a selected customer list (ID) and cost type (Type).

Same as vlookup excel but with two conditions. The first is ID and the second is type.

So to add the column of selected customers to "table 1" with "table 2" marked "yes" or "no"

Please help

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @sgintowt,

 

You may try this Measure.

IsYes Or IsNo =
VAR RelatedType =
    CALCULATE (
        SELECTEDVALUE ( Table2[Type] ),
        FILTER ( Table1, Table1[ID] IN VALUES ( Table2[ID] ) )
    )
RETURN
    IF ( MAX ( Table1[Type] ) = RelatedType, "Yes", "No" )

 

Then, the result will look like this.

vcazhengmsft_0-1653621624705.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know how your tables look like, the relationships you create for them and how you create these two count measures. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi @sgintowt,

 

You may try this Measure.

IsYes Or IsNo =
VAR RelatedType =
    CALCULATE (
        SELECTEDVALUE ( Table2[Type] ),
        FILTER ( Table1, Table1[ID] IN VALUES ( Table2[ID] ) )
    )
RETURN
    IF ( MAX ( Table1[Type] ) = RelatedType, "Yes", "No" )

 

Then, the result will look like this.

vcazhengmsft_0-1653621624705.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know how your tables look like, the relationships you create for them and how you create these two count measures. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

sgintowt
Helper I
Helper I

Table 1

 

IDUserIdDataPriceTypeTypeNettoTaxBruttoYes or NO
68899737124.11.2021nettoFK technologia62,84062,84 
68903207126.11.2021nettoFK technologia124,80124,8 
68890267124.11.2021nettoFK technologia460,820460,82 
6887224199926.11.2021nettoFK Remont127,50127,5 
68901307126.11.2021nettoFK Remont227495232,2727981,27 
38820587126.11.2021nettoFK Remont9020,7110,7 
6890379199924.11.2021nettoFK Remont2682,11616,893299 
3883647199926.11.2021nettoFK Remont474,32109,09583,41 
6890151199926.11.2021nettoFK technologia13,193,0316,22 
6890151199926.11.2021nettoFK technologia32,441,6234,06 
68872247126.11.2021nettoFK technologia501,690501,69 
68898147124.11.2021nettoFK koszty17017 
68878717124.11.2021nettoFK koszty2000200 
68898147124.11.2021nettoFK koszty17017 
6887224199926.11.2021nettoFK koszty141,330141,33 

 

 

Table 2

 

IDType
6889973FK technologia
6890320FK Remont
6889026FK technologia
6887224FK Remont
6890130FK technologia
3882058FK Remont

 

 

I added sample data.

I need to add the "yes or no" column to table 1 with clients who meet the "ID" and Type "conditions

Nathaniel_C
Super User
Super User

Hi @sgintowt ,

Can you provide us with your pbix?


If you would share your pbix, or dummy up some values in Excel both for current and expected data. Please copy and paste them into your post, rather than doing a picture, we may be able to help you. 

Please read this post to get your question answered more quickly:

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

Nathaniel





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

Proud to be a Super User!




Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors