Forum Discussion

syl-ade's avatar
syl-ade
Icon for Helper II rankHelper II
2 years ago
Solved

How to show sum when no filter is applied - USERELATIONSHIP function

Hi all, 

 

I am currently working on HR Analysis Dashboard. I have created measures like Starters and Leavers.

Leaver look like this 

 

Leavers = 
CALCULATE( 
[Count of Employees]
, USERELATIONSHIP(
    'Calendar'[Date]
    , hra_datasource[end_date] 
    )
)

 

 

There is a relationship with the calendar so the correct measure is only shown when date filter is applied. So when date filter is not applied it looks like that:

I would like to see as default the total for leavers and starters of the company. Is there a way to do that in PowerBI?

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi syl-ade ,

    You can update the formula of measure [Leavers] as below and check if it can return the expected result...

    Leavers =
    IF (
        ISFILTERED ( 'Calendar'[Date] ),
        CALCULATE (
            [Count of Employees],
            USERELATIONSHIP ( 'Calendar'[Date], hra_datasource[end_date] )
        ),
        CALCULATE ( [Count of Employees], ALL ( hra_datasource ) )
    )

    If the above ones can't help you figure out, please provide some raw data in your table 'hra_datasource' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi syl-ade ,

    You can update the formula of measure [Leavers] as below and check if it can return the expected result...

    Leavers =
    IF (
        ISFILTERED ( 'Calendar'[Date] ),
        CALCULATE (
            [Count of Employees],
            USERELATIONSHIP ( 'Calendar'[Date], hra_datasource[end_date] )
        ),
        CALCULATE ( [Count of Employees], ALL ( hra_datasource ) )
    )

    If the above ones can't help you figure out, please provide some raw data in your table 'hra_datasource' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards