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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Gjakova
Post Patron
Post Patron

Measure that groups by two different keys?

Hi there, I have the following problem:

I want a DAX script that makes a measure where is added the # of times SickHours> 0 = 1. So if 1 employee key is selected, for example, it will get the number of unique date keys where SickHours> 0 = 1. And if there for example 1 day is selected, I get the number of unique employee keys where Sick Hours> 0 = 1

 

DateKeyEmployeeKeySickHours > 0
411
420
430
411
1610
1621
1631
39011
39031
1 ACCEPTED SOLUTION

Hi @Gjakova ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1602665078556.png

 

Best regards,
Lionel Chen

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

 

View solution in original post

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @Gjakova ,

 

Like this?

 

 

Measure = 
IF(
    ISFILTERED(Sheet3[EmployeeKey]),
    COUNTX(
        FILTER( Sheet3, Sheet3[SickHours > 0] = 1 ),
        [DateKey]
    ),
    IF(
        ISFILTERED(Sheet3[DateKey]),
        COUNTX(
            FILTER( Sheet3, Sheet3[SickHours > 0] = 1 ),
            [EmployeeKey]
        )
    )
)

 

 

v-lionel-msft_0-1602051923542.png

Or like this?

Measure 2 = 
COUNTX(
    FILTER( Sheet3, Sheet3[DateKey] = MAX(Sheet3[DateKey]) && Sheet3[EmployeeKey] = MAX(Sheet3[EmployeeKey]) && Sheet3[SickHours > 0] = 1 ),
    [SickHours > 0]
)

v-lionel-msft_0-1602052142826.png

If not, please show me the expected output result.

 

Best regards,
Lionel Chen

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

 

Hi @v-lionel-msft I think your suggestion will work, I will try it out today. This is my expected output btw:

Gjakova_0-1602052927681.png

The SQL statement would look like this:

count(
           case
                   when SickHours>0
                   then 1
                   else 0
            end)
 
from XXX
 
group by DateKey, Employee

 

Hi @Gjakova ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1602665078556.png

 

Best regards,
Lionel Chen

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

 

amitchandak
Super User
Super User

@Gjakova , Not very clear. Are looking for measure segmentation.

 

refer to my video: https://youtu.be/CuczXPj0N-k

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors