Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dax Formula

Hi all, 

 

 I have a data table like below.  The data table represent an temp worker with the start date and end date. I would like to get a count a daily count of temp worker starting- daily sum of temp worker ending there work. I am trying to get a net value per day. How would I be able to achieve this?

 

  • Hi, 

    According to your description, I can roughly understand your requirement, I think you can try to use this method to achieve your requirement:

    This is the test data I created based on your description:

     

    First you can create a calendar table to place into the date slicer as the selected date, you can change the date range based on your dataset:

    Calendar = CALENDAR(DATE(2021,1,1),DATE(2021,1,5))

     

    Then you can create a measure like this:

    Count of diff =
    
    var _selecteddate=SELECTEDVALUE('Calendar'[Date])
    
    var _CountofStart=COUNTX(FILTER(ALL('Table'),[StartDate]=_selecteddate),'Table'[StaffNameStringId])
    
    var _CountofEnd=COUNTX(FILTER(ALL('Table'),[EndDate]=_selecteddate),'Table'[StaffNameStringId])
    
    return
    
    _CountofStart-_CountofEnd

     

    And you can create a date slicer and a card chart to get what you want, like this:

     

    You can download my test pbix file below

     

    If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

    How to Get Your Question Answered Quickly 

    Thank you very much!

     

    Best Regards,

    Community Support Team _Robert Qin

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

3 Replies

  • v-robertq-msft's avatar
    v-robertq-msft
    Community Support

    Hi, 

    According to your description, I can roughly understand your requirement, I think you can try to use this method to achieve your requirement:

    This is the test data I created based on your description:

     

    First you can create a calendar table to place into the date slicer as the selected date, you can change the date range based on your dataset:

    Calendar = CALENDAR(DATE(2021,1,1),DATE(2021,1,5))

     

    Then you can create a measure like this:

    Count of diff =
    
    var _selecteddate=SELECTEDVALUE('Calendar'[Date])
    
    var _CountofStart=COUNTX(FILTER(ALL('Table'),[StartDate]=_selecteddate),'Table'[StaffNameStringId])
    
    var _CountofEnd=COUNTX(FILTER(ALL('Table'),[EndDate]=_selecteddate),'Table'[StaffNameStringId])
    
    return
    
    _CountofStart-_CountofEnd

     

    And you can create a date slicer and a card chart to get what you want, like this:

     

    You can download my test pbix file below

     

    If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

    How to Get Your Question Answered Quickly 

    Thank you very much!

     

    Best Regards,

    Community Support Team _Robert Qin

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