Forum Discussion
Obtuse SQL Case statement to DAX
- Anonymous8 years ago
Gotcha, that makes sense. I bet you could do this with a single SWITCH though. Something like:
CaseStatement = SWITCH( TRUE(), AND(Status="T", OR(ShippingDate <= TODAY(), complete = 0)), "Trapping", AND(Status="T", OR(ShippingDate > TODAY(), complete <> 0)), "FutureTrapping" )
With AND's and OR's, you can specify the same logic as your SQL. If all of these columns are in different tables, make sure to use RELATED if they have a valid relationship.
Hope this helps,
Parker
Hi Parker,
I should have perhaps mentioned. The business' main database is MySQL - I pull the data in to an MS SQL Warehouse with SSIS, via a staging database where I perform any data manipulations I require. I could have this case statement set the data in the MS SQL warehouse in the SSIS package. Which is what it looks like I will likely end up doing.
This package runs every minute and is very efficient. I don't like making changes to this package and was just hoping to be able to do this via DAX, for now at least. I'm DAX curious and am still learning, so like the challenge.
Many thanks,
Alister
Gotcha, that makes sense. I bet you could do this with a single SWITCH though. Something like:
CaseStatement = SWITCH( TRUE(), AND(Status="T", OR(ShippingDate <= TODAY(), complete = 0)), "Trapping", AND(Status="T", OR(ShippingDate > TODAY(), complete <> 0)), "FutureTrapping" )
With AND's and OR's, you can specify the same logic as your SQL. If all of these columns are in different tables, make sure to use RELATED if they have a valid relationship.
Hope this helps,
Parker