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
StefRenneboog91
Regular Visitor

Beginner level - SUMX - FILTER - SELECTEDVALUE

Hey guys,

 

Thanks a lot already for the one who is willing to help me.

StefRenneboog91_0-1604485939330.png

As you can see in the screenshot, in the table we're having a personnel number (PERNR) , a begin date (BEGDA), an end date (ENDDA) and stating if a user is active or not (STAT2 - if stat 2 = 3 then user is active, if not equal to 3 then he is not active).

The measure I created at this moment looks like this : 

 

Headcount =
SUMX(
Filter(
PA0000,
PA0000[BEGDA] <= SELECTEDVALUE('Date'[Date],TODAY()) &&
PA0000[ENDDA] >= SELECTEDVALUE('Date'[Date],TODAY())
),PA0000[STAT2]/3
)
 
I created a slicer in the report with the date but if I create a report with PERNR + Measure Headcount it's returning 0 records.
To give the example PERNR 200001 (screenshot) should have value 1 for date = 01/01/2020 because BEGDA < 01/01/2020 and ENDDA > 01/01/2020 and STAT2 = 3

I hope someone can help me out with this question.
Thanks a lot again.
KR,
Stef
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @StefRenneboog91 ,

I found that your [BEGDA] and [ENDDA] column is a whole number type instead of a date type so I would suggest you to change these data type of columns to date firstly.

Then, based on your description, you can create this measure to count:

Count =
VAR _count =
    CALCULATE (
        COUNT ( 'Table'[PERNR] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[STAT2] = 3
                && 'Table'[BEGDA] <= SELECTEDVALUE ( 'Date'[Date], TODAY () )
                && 'Table'[ENDDA] >= SELECTEDVALUE ( 'Date'[Date], TODAY () )
        )
    )
RETURN
    IF ( ISBLANK ( _count ), 0, _count )

re.png

Attached a sample file in the below, hopes to help you.

Beginner level - SUMX - FILTER - SELECTEDVALUE.pbix 

 

Best Regards,
Community Support Team _ Yingjie Li
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

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @StefRenneboog91 ,

I found that your [BEGDA] and [ENDDA] column is a whole number type instead of a date type so I would suggest you to change these data type of columns to date firstly.

Then, based on your description, you can create this measure to count:

Count =
VAR _count =
    CALCULATE (
        COUNT ( 'Table'[PERNR] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[STAT2] = 3
                && 'Table'[BEGDA] <= SELECTEDVALUE ( 'Date'[Date], TODAY () )
                && 'Table'[ENDDA] >= SELECTEDVALUE ( 'Date'[Date], TODAY () )
        )
    )
RETURN
    IF ( ISBLANK ( _count ), 0, _count )

re.png

Attached a sample file in the below, hopes to help you.

Beginner level - SUMX - FILTER - SELECTEDVALUE.pbix 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

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.