cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ClaireBear
Helper I
Helper I

How to decode an enum - Bitwise Operations using flag enums for weekdays

Hi, 

I have received a dataset that includes flag enums to tell me what days of the week an employee works. 

I know that:

flag enum 62 means that an employee works Monday to Friday

flag enum 126 means that an emploee works Monday to Saturday and,

flag enum 127 the employee works Monday to Sunday.

 

How do i work this into power bi to decode the enum flag value?

How do i add all combinations with the values for the days of the week? Say someone only works Monday and Tuesday?

I have searched and read up on bitwise operators but nothing comes up on how to decode the enum value in power bi

 

1 - Monday - 1

2 - Tuesday - 2

3 - Wednesday - 4

4 - Thursday - 8

5 - Friday - 16

6 - Saturday - 32

7 - Sunday - 64

 

 Is anyone able to give me some guidence? This is very new to me.

 

Thank you!

4 REPLIES 4
ClaireBear
Helper I
Helper I

Hi @yingyinr 

Thank you so much for your response. 

The DayID in the table below is the enum that i need to decode for the days of the week worked, being Monday to Sunday.  So i need to figure out which days of the week value 62 (for example) is.
Im not sure if there is a calculation that can be done in power bi that decodes these values? 
If not, i suppose the solution would be to find out what days these values represent and build a look up table. 

 

ClaireBear_0-1631258497611.png

 

Hi @ClaireBear ,

I'm afraid that DAX can't implement such a feature, just by using a numerical value to invert the days when the employees work. Besides the table you provided above, are there any other tables in your model associated with this table? I would like to try to see if there is any other information that can be used as an aid to get the days of the week that employees work.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
yingyinr
Community Support
Community Support

Hi @ClaireBear

I don't quite understand your requirement. Are you trying to invert what day of the week each employee works each week based on the sum of the flag enum for each weekday? But again, based on the information you provided, that doesn't seem quite right. For example, flag enum 62 means that an employee works Monday to Friday. In the table below, the values obtained from Monday to Friday are (1+2+4+8+16)=31 not 62...

1 - Monday - 1

2 - Tuesday - 2

3 - Wednesday - 4

4 - Thursday - 8

5 - Friday - 16

6 - Saturday - 32

7 - Sunday - 64

Could you please share the sample data in your model and the results you expect in order to provide you a suitable solution? Also provide a screenshot of the exact calculation logic and the relevant example. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I suspect the enum is actually: 

1 - Sunday - 1

2 - Monday - 2

3 - Tuesday - 4

4 - Wednesday - 8

5 - Thursday - 16

6 - Friday - 32

7 - Saturday - 64

 

Where: Monday to Friday is (2+4+8+16+32)=62.

 

@ClaireBear can you clarify so that we can help?  Thank you.

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors