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.
How do I convert this from SQL to DAX format?
Solved! Go to Solution.
Hi @Ghazaleh
The RELATED function requires that a relationship exists between the current table and the table with related information. If a relationship does not exist between "fp" and "dp", you must create a relationship. You can create a relationship on their common column e.g. Order ID, Payment ID...
Then if you want to add two columns in "fp", you can try the following DAX. You might need to correct the table and column names.
booking_amount =
IF (
RELATED ( 'dp'[payment_status] ) IN { "Approved", "PaidInFull" },
0,
'fp'[revenue_amount_]
)
payment_amount =
IF (
RELATED ( 'dp'[payment_status] ) IN { "Approved", "PaidInFull" },
'fp'[revenue_amount_],
0
)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
@Ghazaleh What's the FROM clause of your SQL statement and how are the fp and dp tables related in Power BI?
A CASE statement is basically a SWITCH function in DAX or a Conditional Column in Power Query.
Use
Booking_amount =
SWITCH ( TRUE(),
dp.payment_status IN {'Approved', 'PaidInFull'} , 0,
fp.revenue_amount_{{currency}}
)
But you'll need to clean up the syntax and table names.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
the payment status comes from a different table (dp) and revenue amount comes from (fp). the approved and paidinfull are values in payment status columns. How can I use "related" function in this case statement to pull these variables from both tables?
Hi @Ghazaleh
The RELATED function requires that a relationship exists between the current table and the table with related information. If a relationship does not exist between "fp" and "dp", you must create a relationship. You can create a relationship on their common column e.g. Order ID, Payment ID...
Then if you want to add two columns in "fp", you can try the following DAX. You might need to correct the table and column names.
booking_amount =
IF (
RELATED ( 'dp'[payment_status] ) IN { "Approved", "PaidInFull" },
0,
'fp'[revenue_amount_]
)
payment_amount =
IF (
RELATED ( 'dp'[payment_status] ) IN { "Approved", "PaidInFull" },
'fp'[revenue_amount_],
0
)
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
96 | |
77 | |
66 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |