Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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 @v-yiruan-msft 

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.
v-yiruan-msft
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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.