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
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

 

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.