Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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 !!!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
73 | |
71 | |
55 | |
38 | |
31 |
User | Count |
---|---|
71 | |
65 | |
60 | |
50 | |
45 |