Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Sum value based on Current Month

Hi,

 

I am trying build a Dax for starting inventory for the month(all open inventory from prior months). However, I cant seem to be able to create the dax for it.

 

So my goal is i want to capture all the received date that has a paid date and blank up to up to 1 month before the date on the date table (For example if the date table is May 20 then i want all th recieved date up to April)

 

I tried using this create column DAX: IF(Recieved date = Complete Date),0,1) however, in May it does not include claim 2 since the recieved date is in 202003 and the complete date is 202005. Is there a way around this? Thank you!!

 

 

Below is my fake data and the table i am tryihng to create.

 

Goal

 Date tableCount
Received dateMar-20 
Received dateApr-204
Received dateMay-205

 

Data

ClaimReceived dateComplete date AprMay
1202003202004 1 
2202003202005 11
3202003202003 0 
4202003  11
5202003202005 11
6202004202005 01
7202004  01
8202004202004 0 
9202005  00
10202005  00
11202005202005 00

 

 

 

2 Replies

  • Anonymous As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

    https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-calculations/

     

    and then use Openingbalancemonth DAX function.

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Weird I think my message got deleted  while I was editing the table to make it look more readable.

       

      parry2k I made the 2 changes per your recommendation and i got really close to the answer. The result I got from the OpeningBalanceMonth(Opening BalanceMonth(Sumx(query1,query[value], date[Month])

       

      Mar - 26,850

      Apr - 24,147

      May - 20,109

       

      However, it does not account for prior month value that are still open. For example, May should be 22,106( 20,109+46+37+1,828 +46) and April should be 25,443 (24,147+1,233+46+37). Is there a way i can edit the DAX to account for the prior months that was not completed till later? Thank you so much for your help

       

        Complete date     
        <3/1/2020MarAprMayJunTotal
      Date RecievedFeb025,5341,233463726,850
       Mar0022,2531,8284624,127
       Apr4090018,3391,36120,109