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

Need help - Showing total staff counts

Good evening all,

 

I am new in DAX code.  Can you share with me DAX code to show total staff counts result if total working hours staffs are more than  Total Man days hours in Table 2. My expected result is Jan - 2 , Feb - 2

 

Appreciated, thanks.

 

Table 1

Staff Total Working Hours 
StaffMonthWeekTotal Working Hours
AJan140
AJan235
AJan337
AJan440
AJan530
BJan138
BJan239
BJan340
BJan430
BJan530
CJan140
CJan240
CJan340
CJan440
CJan530
AFeb135
AFeb240
AFeb340
AFeb430
BFeb140
BFeb235
BFeb330
BFeb425
CFeb130
CFeb230
CFeb332
CFeb435

 

Table 2

Total Man days hours 
Jan180
Feb130
4 REPLIES 4
az38
Community Champion
Community Champion

Hi @Anonymous 

 

first, create a new calculated table

 

Table = 
ADDCOLUMNS(
    SUMMARIZE(
        'Table 1',
        'Table 1'[Month],'Table 1'[Staff],
        "Total hours",SUM('Table 1'[Total Working Hours])
    ),
"Man days hours",IF(CALCULATE(MAX('Table 2'[Total Man days hours]),'Table 2'[Month]=EARLIER([Month])) <= [Total hours],1,0)
)

then put it in visual

Снимок.PNG


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Thanks @az38 for your reply.

 

 

When I write the code until XXX, the system only show the functions instead of showing the column name, how should I continue from here? Thanks.

 

"Man days hours",IF(CALCULATE(MAX('ManTotalHR'[Total Hour],  xxxx
 

PBI.JPG

az38
Community Champion
Community Champion

@Anonymous 

pay attention, you forgot closing parenthesys ")") after MAX sentence


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

My silly mistake.Thanks so much. @az38 

 

 

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