Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count how many days between 2 given dates and plot it

Dear Community, good morning.

 

I am creating a report analyzing the shipment in / out date in order to manage warehousing operations and have the below issue:

 

I have a table containing a data like this, so the cargo ID , the day the cargo arrived at the warehouse and the day that it left the warehouse.

 

Cargo IDEntered DayReleased Date
A01/01/202103/01/2021
B02/01/202104/01/2021
C01/01/202102/01/2021

 

What I need to do is create a graph showing the total cargoes by date, so I would neet to change the table to something like this:

 

Cargo IDDay
A01/01/2021
A02/01/2021
A03/01/2021
B02/01/2021
B03/01/2021
B04/01/2021
C01/01/2021
C02/01/2021

 

And plot like below:

 

What is the best way to do this?

 

Thank you in advance!

 

  • Click here to download a solution 

     

    You need to build a calendar table with contagious dates

    the create this measure ..

     

    Valid cargos =
    VAR mydate = SELECTEDVALUE('Calendar'[Date])
    VAR validrows = FILTER(Cargos, Cargos[Entered Day] <= mydate && Cargos[Released Date] >= mydate)
    RETURN
     
    Then use calendar date in you graph x-axis and the [Valid cargos ] as the Y-axis value
    COUNTROWS(validrows)
     

    Thanks for reaching out for help.

    I have helped you, now please help me by giving kudos.

    Remeber we are unpaid volunteers.

    Click the thumbs up and accept as solution button. 

    One question per ticket please. If you need to extend your request then please raise a new ticket.

    You will get a quicker response and each volnteer solver will get the kudos they deserve. Thank you !

3 Replies

  • Click here to download a solution 

     

    You need to build a calendar table with contagious dates

    the create this measure ..

     

    Valid cargos =
    VAR mydate = SELECTEDVALUE('Calendar'[Date])
    VAR validrows = FILTER(Cargos, Cargos[Entered Day] <= mydate && Cargos[Released Date] >= mydate)
    RETURN
     
    Then use calendar date in you graph x-axis and the [Valid cargos ] as the Y-axis value
    COUNTROWS(validrows)
     

    Thanks for reaching out for help.

    I have helped you, now please help me by giving kudos.

    Remeber we are unpaid volunteers.

    Click the thumbs up and accept as solution button. 

    One question per ticket please. If you need to extend your request then please raise a new ticket.

    You will get a quicker response and each volnteer solver will get the kudos they deserve. Thank you !

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello Speedramps,

       

      First, thank you for the quick reply! Much appreciated.

       

      Quick question as I saw your PBIX, you use the date calendar without the hierarchy, but I need to be able to freely go to lets say quarter total, month total and day.

       

      Is it possible?

       

       

  • Hi agian Pedro

     

    Thanks for accepting the solution  😀

     

    I am a vounteer. Please try ask one question per ticket. That way I get twice the solving score ! 😀😀

    Quote speedramps and I will received a notofication, but other solvers may help.

     

    I recommend you turn off auto date integence .  Only novices use it.

    It you want to be a serious Power Bi developer then build a Calender table, test it once and use it always ...

    Do all these tutorials a few times and you will become an expert at YTD, MTD, LY, LM, Quarters  ...   

    Click here to start learning 

     

    You will also need to change the measure if you use Month or Quarters in your X-axis.

     
    Valid cargos =
    VAR mindate = MIN('Calendar'[Date])
    VAR maxdate = MIN('Calendar'[Date])
    VAR validrows = FILTER(CargosCargos[Entered Day] <= maxdate && Cargos[Released Date] >= mindate)
    RETURN

     

    Thanks for reaching out for help.

    I have helped you, now please help me by giving kudos.

    Remeber we are unpaid volunteers.

    Click the thumbs up and accept as solution button. 

    One question per ticket please. If you need to extend your request then please raise a new ticket.

    You will get a quicker response and each volnteer solver will get the kudos they deserve. Thank you ! 😎