Forum Discussion

FN's avatar
FN
Regular Visitor
9 years ago

Time Intelligence Measures with dynamic Time Periods

Hello together,

 

I am working on a Power BI report and wasn't able to find a solution for my problem so far.

 

I want to calculate a so called Cancellation Rate for my company, meaning how many contracts were active at the beginning of a period (e.g. 01/01/2015) and how many of these contracts were cancelled in a certain period (e.g. from 01/01/2015 until 12/31/2015) and then calculating the percentage.

Therefore I am importing all contracts from the CRM into Power Bi. Every Contract has a Contract Start Date and a Contract End Date.

 

I used to calculate this in Excel with
=SUMIFS(Revenue; Contract Start Date < DateX; Contract End Date > DateX)

to calculate how many contracts were active on a certain DateX, e.g. 01/01/2015.

 

Do you have any recommendations on how I could solve this in Power BI?

My goal would be to have all the different periods in a chart on the axis and the according percentage as the value.

I would be so thankful if someone here could help me.

Regards,
Florian

9 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Microsoft Employee

    Hi FN,

     

    Any chance you can post a sample set of data, including a mock up of what you might expect once you have everything working?

     

    Cheers,

     

    Phil

    • FN's avatar
      FN
      Regular Visitor

      Hi Phil,

       

      Yes, here I have some sample data:

       

      So this is my model with the realtionships:

       

      Account = All the Customers with its information regarding the customer's adress, country, etc.

      Contract = All Contracts with information like Contract Start Date, Contract End Date, etc (matched to Account with the Customer ID)

      Subterritories = More detailled analysis for regions, so I match a subterritory (like UK) from the Customer's account to the firm of the company, Regions, etc. (not really important for the problem here)

      Exchange Rate = As we have contracts in many countries, I am matching the currency from contract to Exchange rate (also not really important for this problem)

      Dates = I don't know if this is necessary. It is a date table, with dates in it. As I want to measure the different things (Active Revenue, Cancelled Revenue) on a quarterly period, so I have all the dates of the start of a quarter period there, e.g. 01/01/2015, 04/01/2015, 07/01/2015 and so on. Then I am referring to this date when I am calculating how much revenue was valid at a certain date. Also the same with expired contracts. So far everything clear?

       

       

      So at the moment, I am calculating the revenue that is valid like this:

      =CALCULATE(SUM(Revenue); FILTER(Contracts, Contract Start Date < Dates.QuarterBeginnDate); FILTER(Contracts, Contract End Date > Dates.QuarterBeginnDate)

      It is an extra column, because when I try to calculate is as a measure, the 'Dates.QuarterBeginnDate' is not possible to select in the formula from above. I don't know the reason.

      Same for the expired contracts:

      =CALCULATE(SUM(Revenue);FILTER(Contracts, Contract Start Date < Dates.QuarterBeginnDate); FILTER(Contract End Date > Dates.QuarterBeginnDate); FILTER(Contract End Date > Dates.Period End Date)

       

      Like this, I am calculating a percentage. Also here, it is again not possible to create a measure, because these column names do not appear when I try to enter it in the formula. So I created an extra column again.

       

      What I would love to have is something like this:

       

      So to calculate a rate for every period. This is how I did it in Excel and then I graph it in a chart.

       

      What I want in Power BI is basically the same, to calculate this (only for help) and then graph the rates in a chart. What I want is that with Slicer in Power BI I can easily re calculate the rates for different contract types, for different countries, for different Sales Partner. I don't know in this case if Power BI with its time intelligence is intelligent enough to aleady calculate the rates for periods itself or if I need these date tables or maybe something different.

      Do you have any idea of how I could do that?


      Thank you and Regards,
      Florian

       

    • FN's avatar
      FN
      Regular Visitor

      Phil_Seamark

      v-huizhn-msft

       

      I don't know if you receive a notification when I didn't mark you in my replying post.

      If you received a notification, then I am sorry for this post. :)

       

      Thank you so much for your help,

      Florian

      • Phil_Seamark's avatar
        Phil_Seamark
        Microsoft Employee

        Hi FN,

         

        Any chance you can share some sample data in text form rather than as an image to save lots of key-ing in :)

         

         

  • v-huizhn-msft's avatar
    v-huizhn-msft
    Microsoft Employee

    Hi FN,

    Based on my understanding, you can transfer the formula to DAX, which is used to create a measure.

    active amount=CALCULATE(SUM(Table[Revenue]),Filter(Table, AND(Table[contract start data]<DateX[Date],Table[contract end data]>DateX[Date])))


    Then create a measure to calculate the amount of concelled contracts.

     

    concelled amount=CALCULATE(SUM(Table[Revenue]),Filter(Table, Table[contract end data]>=DateX[Date1],Table[contract end data]<=DateX[Date2])))


    Then calculate the percentage.

    percentage=[active amount]/[concelled amount]


    Then you can create a line chart, then select the Datex[Date] as axis, the [percentage] as value level, you will get expected result.

    If this is not want you want, please post the sample data as Phil_Seamark suggested.

    Best Regards,
    Angelia

    • FN's avatar
      FN
      Regular Visitor

      Hi Angelia,

       

      I posted some sample data minutes ago.
      I already tried it like in your suggestion, but as the coloumns Dates['Period Dates'] and Contracts['Contract Start Date'] are in different tables, I can't refere to both in one measure unfortunately, but I can do so in an extra column. I don't know why this is the case or what I am doing wrong here.

       

      This is the column I have:

       

      Do you know why this doesn't work as a measure?

      In the analysis part I then want to split this rate up into different contract types, regions, etc. As long as the rate is just an extra column it is not working unfortunately.

       

      Thank you,

      Florian