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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculated column to mark database with 1 and 0 based on a measure

Hi everyone! I need help with a calculated column that marks with 1 when a person with a certain kind of Function worked 7 shifts on a week. I found a way to calculate this with a measure:

 

M7HT = 
COUNTROWS(
    FILTER(
        SUMMARIZE(BD,BD[Week],BD[WorkerID]
        ,"Count7",COUNT(BD[WorkerID]))
        ,[Count7]=7
            )
)
 

With this measure everythings works great, and I can cover the Function problem by filtering my reports with let's say Function ="X"
So the thing is, I need to pass this to a calculated column because I need to visualize the date when the person with the X Function worked the 7th shift, I need to visualize how many times on a month the person worked a 7th shift, I need to know the average of 7th shifts that all workers with the "X" Function did on a certain period, etc. And the measure doesn't solve all that. Could you please help me? I can't figure it out and I really need it. I think this has to do with iterators? If you can also help me with some content about that subject to learn more it would be great,

Thank you for your time,
Best regards,
Gabriela

4 REPLIES 4
Greg_Deckler
Super User
Super User

Need some more information, what table are you creating this in? Sample data would be great. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler sorry I forgot to give more context, right now I can't share you the data, but the table looks like this

 

WorkerIDFunctionDateShiftWeek

A

X01-01-202011
AX02-01-202021
BY01-01-202011
BY01-01-202021

 

Basically you have a row for everytime the worker worked on a certain date doing a certain function. There are three shifts every day, so the person can work more than two times a day, I don't know if that information is relevant, but that's pretty much the whole picture, I hope the scenario is clearer,




 

OK, so is that your BD table?

 

If that is the case, you might need to do something like:

 

M7HT Column = 
  VAR __WorkerID = [WorkerID]
RETURN
  CALCULATE([M7HT],FILTER(ALL('BD'),[WorkerID]=__WorkerID))

 

When this measure "works", how are you displaying it? What other columns/tables are in the visualization with the measure?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Yes, that's the BD table. To see the measure working I usually see the total of 7th shifts worked month by month, or the quantity of people who did more than 7 shifts on a week v/s the ones that worked less than 6, so I basically use the same Date hierarchy and also I filtered the workers with the X Function, so there are no more columns/tables involved. I tried the formula, but it didn't worked, it displays a repeated number, not the 1s and 0s as I need and it also doesn't take account of the X Function in its calculation,

Greetings!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors