The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi Below is my SWITCH in DAX which is working perfectly . Now I want to add a new condition by joining on another table. the join relation already exists in the model.
basically join on table called Development and we need to add another condition to the below which says WHERE Development.FLAG = 'FALSE'. Also i need to add another VALUE in this switch called 'NHT' and the condition for this is WHERE Development.FLAG = 'TRUE' THEN 'NHT'
can someone please update my below SWITCH to my new condition's please ? Many Thanks
record_type_report = SWITCH( TRUE(),[Recordtypename__c] = "Places Development OS","Open Market",
[Recordtypename__c] = "Places Development SO","Shared Ownership",
[Recordtypename__c] = "Places Development SE","Shared Equity",
[Recordtypename__c])
Solved! Go to Solution.
Hi @Anonymous
Please @ mention me in replies or I'll miss your response. Type @ then select my name.
Download sample PBIX with the following code and data
No it won't but I've amended the code to this which does work. RELATED needs a row context to work so I'm using LOOKUPVALUE on the related Development table.
record_type_report =
VAR __Flag = LOOKUPVALUE('Development'[Flag], 'Development'[Value], SELECTEDVALUE('Table'[Value]))
RETURN
SWITCH(
TRUE(),
[Recordtypename__c] = "Places Development OS" && __Flag = FALSE ,"Open Market",
[Recordtypename__c] = "Places Development SO" && __Flag = FALSE ,"Shared Ownership",
[Recordtypename__c] = "Places Development SE" && __Flag = FALSE ,"Shared Equity",
__Flag = TRUE, "NHT",
[Recordtypename__c]
)
Which gives this
Is that the result you were looking for when 'Development'[Flag] = True to give NHT ?
Regards
Phil
Proud to be a Super User!
Hi @Anonymous
Please @ mention me in replies or I'll miss your response. Type @ then select my name.
Download sample PBIX with the following code and data
No it won't but I've amended the code to this which does work. RELATED needs a row context to work so I'm using LOOKUPVALUE on the related Development table.
record_type_report =
VAR __Flag = LOOKUPVALUE('Development'[Flag], 'Development'[Value], SELECTEDVALUE('Table'[Value]))
RETURN
SWITCH(
TRUE(),
[Recordtypename__c] = "Places Development OS" && __Flag = FALSE ,"Open Market",
[Recordtypename__c] = "Places Development SO" && __Flag = FALSE ,"Shared Ownership",
[Recordtypename__c] = "Places Development SE" && __Flag = FALSE ,"Shared Equity",
__Flag = TRUE, "NHT",
[Recordtypename__c]
)
Which gives this
Is that the result you were looking for when 'Development'[Flag] = True to give NHT ?
Regards
Phil
Proud to be a Super User!
Hi Phil, but will that work without using the RELATED function as you are joining with another table ? thanks
Hi @Anonymous
Try this
record_type_report = SWITCH(
TRUE(),
[Recordtypename__c] = "Places Development OS" && 'Development'[Flag] = FALSE ,"Open Market",
[Recordtypename__c] = "Places Development SO" && 'Development'[Flag] = FALSE ,"Shared Ownership",
[Recordtypename__c] = "Places Development SE" && 'Development'[Flag] = FALSE ,"Shared Equity",
'Development'[Flag] = TRUE, "NHT"
[Recordtypename__c]
)
There are some assumptions here:
1. Flag is a column in the Development table.
2. This Flad column is Boolean True/False. If it contains text then you need to change the TRUE/FALSE values in the code above to strings e.g. "True" and "False"
Regards
Phil
Proud to be a Super User!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
114 | |
80 | |
78 | |
44 | |
39 |
User | Count |
---|---|
150 | |
116 | |
68 | |
64 | |
57 |