The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
My data model has a SQL table with a bunch of appointments. The appointments have a series of flags that are used to infer the status of the appointment, they are all string columns with a Y or N value, and a date value.
The logic looks like this:
IF isCancelled = Y then "Cancelled"
IF isDeleted = Y then "Deleted"
IF isRescheduled = Y then "Rescheduled"
IF isKept = Y then "Kept"
IF isCancelled = N & isDeleted = N & isRescheduled = N & isKept = N & appointmentDate >= NOW() then "Expected"
IF isCancelled = N & isDeleted = N & isRescheduled = N & isKept = N & appointmentDate < NOW() then "No Show"
I'd like to create a calculated columns that more easily allows me to build reports from this data. My goal would be to have the column just display the current status of the appointment.
I can't figure out how to do a bitwise operation in DAX logic. Because of the date constraint do I have to do this with a measure?
If i can do it in the query builder instead of a measure, is there a benefit to either?
My thinking would be to use a bitwise operation, something where I set the column to 00000 and then flip each bit for the appropriate status?
Is there an easier way?
Solved! Go to Solution.
Please create this calculated column in your table
LOGIC = SWITCH ( TRUE; Table1[isCancelled ] = "Y"; "Cancelled"; Table1[isDeleted ] = "Y"; "Deleted"; Table1[isRescheduled ] = "Y"; "Rescheduled"; Table1[isKept ] = "Y"; "Kept"; Table1[isCancelled ] = "N" && Table1[isDeleted ] = "N" && Table1[isRescheduled ] = "N" && Table1[isCancelled ] = "N" && Table1[appointmentDate ] >= NOW (); "Expected"; Table1[isCancelled ] = "N" && Table1[isDeleted ] = "N" && Table1[isRescheduled ] = "N" && Table1[isCancelled ] = "N" && Table1[appointmentDate ] < NOW (); "No Show"; BLANK () )
I try it and works well !!!
Please create this calculated column in your table
LOGIC = SWITCH ( TRUE; Table1[isCancelled ] = "Y"; "Cancelled"; Table1[isDeleted ] = "Y"; "Deleted"; Table1[isRescheduled ] = "Y"; "Rescheduled"; Table1[isKept ] = "Y"; "Kept"; Table1[isCancelled ] = "N" && Table1[isDeleted ] = "N" && Table1[isRescheduled ] = "N" && Table1[isCancelled ] = "N" && Table1[appointmentDate ] >= NOW (); "Expected"; Table1[isCancelled ] = "N" && Table1[isDeleted ] = "N" && Table1[isRescheduled ] = "N" && Table1[isCancelled ] = "N" && Table1[appointmentDate ] < NOW (); "No Show"; BLANK () )
I try it and works well !!!