Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 !!!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
71 | |
70 | |
38 | |
28 | |
26 |
User | Count |
---|---|
97 | |
88 | |
59 | |
43 | |
40 |