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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hannes86
Frequent Visitor

logical comparison (true/false) on different columns in different tables

Hi there,

 

up front: I am a beginner in Power BI, DAX and Power Query.

 

I have the following problem:

 

Table "auction_results" contains data regarding projects that were awarded a tariff. Some the awarded projects also already have a permit which is a prerequisite to start operations. If this is the case the column "permit_id" contains a unique id. If not, the cell is empty.

 

Table "permit_data" contains detailed information on every project that obtained a permit for operations. Only some of these have already been awarded a tariff in the auctions. Every entry in this table has a "Anlagennummer" which is the connecting link to the "permit_id".

 

I have estbalished a n:1 relationship permit_id:Anlagennummer (was the only valid cardinality). My goal is to insert a conditional column named "tariff_status" in the table "Permit Data" that indicates whether the permitted project was already awarded a tariff or not. I tried the whole day at first using power query and afterwards DAX but I failed. In Power Query I did not find a function that equals the RELATED Function in DAX. In DAX I could only use RELATED in "permit_id", I guess because this is the n tables...?

 

As solution I would have expected sth like:

 

tariff = IF('permit_data'[Anlagennummer] = RELATED('auction_results'[permit_id]);"Yes";"No")

Out of desperation I also tried it the other way around:

 

 

permit_status = IF('auction_results'[permit_id] = RELATED('permit_data'[Anlagennummer]);"permitted"; "not permitted")

Whereas the first code showed nothing in table "permit_data", the second showed "permitted" for every project in table "auction_results" regardless whether the project was permitted or not...

 

 

Happy for help. It's probably very easy for you.

6 REPLIES 6
hannes86
Frequent Visitor

No one?

 

Do you need more information?

HI @hannes86,

 

I'd like to suggest drag Tariff measure to visual level filter of map visual and filter true value to achieve your requirement.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft,

thank you for your reply.

 

My quesation rather was: How do I calculate the values yes/no in column "tariff" based on the information of Table1: 'auction_results' and Table2: 'permit_data'. If the value in column "Anlagennummer" in Table2 equals the value in column "permit_id" in Table1 then "Yes" if not "No".

 

As solution I would have expected sth like below, but it did not work.

 

tariff = IF('permit_data'[Anlagennummer] = RELATED('auction_results'[permit_id]);"Yes";"No")

 

Current relationships:

auction results          permit_data

permit_id             n:1  Anlagennummer

 

Thank you.

 

Hannes

Hi @hannes86,

 

Power bi not support create dynamic calculate column/table based on filter/slicer, so your requirement can't be achieved.

 

You can only use measure to achieve dynamic calculation.

Calculated Column/Table Change Dynamically According to Slicer Selection in the Report.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Greg_Deckler
Super User
Super User

Sample data please.

 

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

INPUT

 

Table1: 'auction_results'

bidderbid_idaward_idtransaction_noquantityWTG_nbid_id_WTGpermit_id
bidder1 WIN18-1-00111542040502311WIN18-1-001-01A4497640206941
bidder2 WIN18-1-00211542099999911WIN18-1-002-01 

 

Table2: 'permit_data'

datenotificationAnlagennummerOEMTypeHeightDiameter
12.10.2015permitA1139377067008Siemens Wind Power GmbH & Co. KGSWT-6.0-154110154
21.12.2017permitA4497640206941ENERCON GmbHE-115 E2149,1115,7

 

Current relationships:

auction results          permit_data

permit_id             n:1  Anlagennummer

 

Desired OUTPUT:

datenotificationAnlagennummerOEMTypeHeightDiameterTariff
12.10.2015permitA1139377067008Siemens Wind Power GmbH & Co. KGSWT-6.0-154110154no
21.12.2017permitA4497640206941ENERCON GmbHE-115 E2149,1115,7yes 

 

Desired Visualization afterwards

Example: Show only projects/volumes with a permit but without a tariff

Unbenannt.PNG

 

I hope this helps

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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