Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

calculate sum between two dates

Hi All ,

I want to calculate the running total of license quntity between start_date_updated and expried date  in a bar chart where i show the data in month wise . 

 

 two date fields are inactive releationship with master calender as shown below 

 

I tried writing DAX logic but i m facing ambiguity in relationships.

Please help with DAX logic . 

 

amitchandak Greg_Deckler 

13 Replies

  • Anonymous , Seem like you need active count, refer if these can help

     

    Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
    https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

    Power BI HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU

     

     

    In case you need cumulative of active

     

    you can try like

     

    Cumm Sales = CALCULATE(SUMX(values(Date[Date]),[Active Measure]),filter(allselected(date),date[date] <=max(date[Date])))

    • Anonymous's avatar
      Anonymous
      Not applicable

      i have seen the HR analytics logics and i have implemented it .. but i m not getting correct results .. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

      We need to calculate running total of license qty between start and end date . Where both the dates are inactive releationship with master calender as shown in my post

       

      Below is the data

      Licence QtyStart _dateExpired _date
      148,3611/1/202112/31/2021
      8021/28/202112/31/2021
      3342/24/202112/31/2021
      2192/23/202112/31/2021
      1852/25/202112/31/2021
      1502/1/202112/31/2021
      152/21/202112/31/2021
      2703/23/202112/31/2021
      1023/11/202112/31/2021
      373/31/202112/31/2021
      1983/28/202112/31/2021
      453/22/202112/31/2021
      133/16/202112/31/2021
      173/24/202112/31/2021
      1593/8/202112/31/2021
      1063/31/202112/30/2021
      2283/9/202112/31/2021
      2453/18/202112/31/2021
      2423/15/202112/31/2021
      1294/6/202112/31/2021
      1184/29/202112/31/2021
      84/22/202112/31/2021
      124/30/202112/31/2021
      304/29/202112/30/2021
      164/23/202112/31/2021
      544/12/202112/31/2021
      634/20/202112/31/2021
      14/23/202112/30/2021
      1415/5/202112/31/2021
      1865/4/202112/31/2021
      15/24/202112/30/2021
      195/20/202112/31/2021
      2265/12/202112/31/2021
      635/24/202112/31/2021
      165/28/202112/31/2021
      205/27/202112/31/2021
      725/14/202112/31/2021
      715/25/202112/31/2021
      55/6/202112/30/2021
      3745/19/202112/31/2021
      2745/2/202112/30/2021
      245/9/202112/30/2021
      895/6/202112/31/2021
      135/11/202112/30/2021
      605/3/202112/31/2021
      135/13/202112/30/2021
      265/10/202112/30/2021
      45/17/202112/31/2021
      45/11/202112/31/2021
      15/12/202112/30/2021
      155/13/202112/31/2021
      25/31/202112/30/2021

       

      Expected Output

      MonthSum(License Qty)Rolling License Qty
      1149,163149,163
      2903150,066
      31662151,728
      4431152,159
      51719153,878

       

  • Hi,

    Shares some data (in a format the can be pasted in an MS Excel file), explain the question and show the expected result.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

      We need to calculate running total of license qty between start and end date . Where both the dates are inactive releationship with master calender as shown in my post

       

      Below is the data

      Licence QtyStart _dateExpired _date
      148,3611/1/202112/31/2021
      8021/28/202112/31/2021
      3342/24/202112/31/2021
      2192/23/202112/31/2021
      1852/25/202112/31/2021
      1502/1/202112/31/2021
      152/21/202112/31/2021
      2703/23/202112/31/2021
      1023/11/202112/31/2021
      373/31/202112/31/2021
      1983/28/202112/31/2021
      453/22/202112/31/2021
      133/16/202112/31/2021
      173/24/202112/31/2021
      1593/8/202112/31/2021
      1063/31/202112/30/2021
      2283/9/202112/31/2021
      2453/18/202112/31/2021
      2423/15/202112/31/2021
      1294/6/202112/31/2021
      1184/29/202112/31/2021
      84/22/202112/31/2021
      124/30/202112/31/2021
      304/29/202112/30/2021
      164/23/202112/31/2021
      544/12/202112/31/2021
      634/20/202112/31/2021
      14/23/202112/30/2021
      1415/5/202112/31/2021
      1865/4/202112/31/2021
      15/24/202112/30/2021
      195/20/202112/31/2021
      2265/12/202112/31/2021
      635/24/202112/31/2021
      165/28/202112/31/2021
      205/27/202112/31/2021
      725/14/202112/31/2021
      715/25/202112/31/2021
      55/6/202112/30/2021
      3745/19/202112/31/2021
      2745/2/202112/30/2021
      245/9/202112/30/2021
      895/6/202112/31/2021
      135/11/202112/30/2021
      605/3/202112/31/2021
      135/13/202112/30/2021
      265/10/202112/30/2021
      45/17/202112/31/2021
      45/11/202112/31/2021
      15/12/202112/30/2021
      155/13/202112/31/2021
      25/31/202112/30/2021

       

      Expected Output

      MonthSum(License Qty)Rolling License Qty
      1149,163149,163
      2903150,066
      31662151,728
      4431152,159
      51719153,878

       

       

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        The way you have described it, there is no use of the Expiry date column.  You may download my PBI file from here.

        Hope this helps.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Sir Need to calculate the sum of license qty between the start date and expried date . need to exclude the records if  Difference between start and expored date is greater than 365 days . 

      in my power bi report , i have two table . One table is given below and another table is master calender .

      Below is the sample data 

      start_dateexpired_datelicense_quantity
      1/1/201612/31/201615
      12/31/202112/30/2022167
      1/1/201912/31/2019176
      3/23/202012/31/202030
      3/23/202012/31/2020150
      1/1/202012/31/2020150
      1/1/201812/31/2018-25
      1/1/201812/31/201835
      1/1/201612/31/201686
      12/12/201412/31/2014107
      2/10/202212/31/2022165
      1/1/202112/31/2021121
      1/1/201912/31/20193
      1/1/201912/31/2019184
      1/1/202112/31/2021121
      9/9/201812/31/20181
      9/9/201812/31/20182
      9/9/201812/31/20181
      9/9/201812/31/20181
      9/9/201812/31/20181
      9/9/201812/31/20181
      9/9/201812/31/2018169
      1/1/201912/31/20193
      1/1/201912/31/2019184
      1/1/202312/31/202321
      5/4/202112/31/20211
      2/18/20213/26/20211
      2/18/20213/26/20211
      1/1/202112/31/20211
      1/1/202112/31/202118
      11/12/202012/30/20201
      5/4/202112/31/20211
      2/18/20213/26/20211
      2/18/20213/26/20211
      1/1/202112/31/20211
      10/25/202112/31/202120
      9/2/202112/31/2021200
      1/1/202012/31/202013
      1/1/201912/31/20195
      1/1/201912/31/201910
      1/1/201912/31/20195
      1/1/201712/31/2017246
      1/1/201812/31/2018200
      2/25/202212/31/2022141
      12/31/202112/30/202279
      1/1/202112/31/202110
      1/1/202112/31/202174
      1/1/202012/31/20201
      1/1/202012/31/202085
      2/19/201912/31/201915
      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        As requested in my message on January 19, 2023, show the expected result very clearly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Sir

      for the given below sample data we need calculate rolling sum per year . 

      Please help me sir ..