Forum Discussion

jonathan_nz's avatar
jonathan_nz
Frequent Visitor
9 years ago

Assigning a Date to a Calculated Column or Measure then Displyaing using a Clustered Column Chart

I need help with creating a Clustered Column Chart. I am a Power Bi novice (couple of months under my belt).

 

The problem:

 

I am working with sales data that is generated over multiple months (its a rental car business).

 

For example, a booking will have a pickup date of say 30 January and a drop off date of say 5 February. I have used a calculated column to allocate the number of 'booking days' across the different months (i.e. 2 days in January and 5 days in February). This calculated column is then multiplied by the daily rate to get revenue per month. I have 12 calculated columns (or measures) for the 2017 calendar year (one for each month). I have tried to graph this data but the results are not satisfactory when you have 12 months of data (the columns get smaller and smaller).

 

What I need to do is somehow assign a date to each monthly sales total but am struggling to do this. I have tried to create a 'date' column using if statements but this does not seem to work as the sales data is over multiple time periods / columns and the if statement can only assign one date per row. I need to somehow 'fix' or create an 'absolute' sales amount per month and then assign a date to that fixed amount - but I can't work out how to do this.

 

Monthly Sales (note: no shared axis value - this needs to be in months)

 

 

 

 

This is what happens if I use an if statement to assign a date, it picks up February sales (dark green) where there is also a January sale (i.e. a booking across multiple months) and includes the result in January. This data should be in February (and combine with the other February data). You will note that there is now a shared axis though (which is want I am after) and visually the clustered column chart looks better.

 

Thanks in advance for any assistance you can provide. I am wasting way too much time on this!

 

If you want to look at my DAX formulas let me know. They are all pretty basic. 

 

Regards, Jonathan

 

3 Replies

  • You explained well, but it will be nice to see some sample data to provide help.

    • jonathan_nz's avatar
      jonathan_nz
      Frequent Visitor

      Sure, I'm not sure how to upload an excel file, so here is a snapshot of the data I am working with:

       

      pickup_datedropoff_date7 - Total Day Count6 - Daily SalesC - January 2017 Day CountC - February 2017 Day CountM - January 2017 SalesM - February 2017 Sales
      30/09/20166/02/2017129$42.90316$1,329.90$257.40
      6/01/201730/03/201783$72.682528$1,817.00$2,035.04
      10/01/201727/03/201776$42.142128$884.94$1,179.92
      3/11/20167/01/201765$68.937 $482.51 
      7/11/20164/01/201758$88.724 $354.88 
      18/11/201613/01/201756$44.6413 $580.32 
      8/02/201727/03/201747$59.44 20 $1,188.73
      10/12/201624/01/201745$48.9224 $1,174.08 
      20/01/20173/03/201742$47.941128$527.31$1,342.24

       

      Dates are in NZ format, so the day and month are opposite to the US convention.

       

      Cheers, Jonathan

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi jonathan_nz,

         

        It is hard to use measure or calculate column to modify the display graphic, perhaps you can try to write a measure to calculate the next month amount based on current month.

         

        Regards,

        Xiaoxin Sheng