Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Measure calculation based on month slicer

Hi,

 

I have a dataset which contains the outstanding invoices for our customers at the end of each month + the YTD sales at the end of each month: so for January an overview of the outstanding invoices at 31.01.2020 and the YTD sales for january, for february the outstanding invoices at 29.02.2020 and the YTD sales for february.

 

I want to calculate the amount of days outstanding with the following calculation: (open items * month * 30) / YTD sales. 

The month should be based off my selection in a slicer; for January the calculation should be (open items * 1 * 30) / YTD sales, for April it should be (open items * 4 * 30) / YTD sales.

 

Is what i'm asking possible?

 

Below you can find a small sample of my dataset

 

Fiscal YearMonthName 1Posting Date Amount in local currency CurrencyCategory
2020JanuariCustomer 131/01/2020340.00EUROpen items
2020JanuariCustomer 131/01/2020500.00EUROpen items
2020JanuariCustomer 231/01/2020670.00EUROpen items
2020JanuariCustomer 331/01/2020800.00EUROpen items
2020JanuariCustomer 531/01/2020920.00EUROpen items
2020MaartCustomer 430/03/2020       120.00  EUROpen items
2020MaartCustomer 230/03/2020       200.00  EUROpen items
2020MaartCustomer 330/03/2020       670.00  EUROpen items
2020MaartCustomer 530/03/2020       900.00  EUROpen items
2020FebruariCustomer 431/01/2020    1,200.00  EUROpen items
2020FebruariCustomer 319/07/2018    1,340.00  EUROpen items
2020FebruariCustomer 21/01/2017    1,200.00  EUROpen items
2020FebruariCustomer 41/01/2017    1,500.00  EUROpen items
2020Januari         100.00   Sales
2020Januari         200.00   Sales
2020Januari         300.00   Sales
2020Januari         400.00   Sales
2020Januari         100.00   Sales
2020Januari         200.00   Sales
2020Januari         300.00   Sales
2020Februari         500.00   Sales
2020Februari         300.00   Sales
2020Februari         500.00   Sales
2020Februari         700.00   Sales
2020Februari         500.00   Sales
2020Februari         300.00   Sales
2020Februari         500.00   Sales
2020Maart         800.00   Sales
2020Maart         700.00   Sales
2020Maart         600.00   Sales
2020Maart         900.00   Sales
2020Maart         800.00   Sales
2020Maart         700.00   Sales
2020Maart         600.00   Sales
  • Anonymous's avatar
    Anonymous
    6 years ago

    Thanks for the suggestions, found the solution in the meanwhile.

     

    Adding a calculation around the divide formula gave the desired result.

3 Replies

  • Anonymous , Not clear try like

    YTD Sales = CALCULATE(SUM(Table[Amount]),DATESYTD('Date'[Date],"12/31"),Table[Category] ="Sales")

    or

    YTD Sales = CALCULATE(SUM(Table[Amount]),DATESYTD('Date'[Date],"12/31"),filter(Table,Table[Category] ="Sales"))

     

    open items = CALCULATE(Count(Table[Amount]),filter(Table,Table[Category] ="Open Items")) // replace count with sum if needed

     

    new measure =divide([open items] * month(max(Table[Posting Date]) )* 30 ,[YTD Sales ])

     

     

    Power BI — YTD
    https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

     

    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
    https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
    https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
    https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

    See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


    Appreciate your Kudos.

     

    or Averagex(Values(Table[Month],divide([open items] * month(max(Table[Posting Date]) )* 30 ,[YTD Sales ]))

     

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Do you want to calculate the Total open item in selected month / YTD sales.

    For example, we select Jan, it will calculate the Total open item in Jan and the Total * 1 * 30, then the vaule / sales in Jan.

    Based on your sample data, it will be (340 + 500 + 670 + 800 +920) * 1 *30 / (100 + 200 + 300 +400 + 100 + 200 + 300)

     

     

    If yes, we can create two measures to meet your requirement.

     

    YTD Sales = 
    CALCULATE(SUM('Table'[ Amount in local currency ]),FILTER(ALL('Table'),'Table'[Category]="Sales"&&'Table'[Month]<=MAX('Table'[Month])))

     

    Result = 
    var _select = SELECTEDVALUE('Table'[Month name],"Jan")
    var _select_month = CALCULATE(MAX('Table'[Month]),FILTER('Table','Table'[Month name]=_select))
    var _Open = CALCULATE(SUM('Table'[ Amount in local currency ]),FILTER('Table','Table'[Category]="Open items")) * _select_month * 30
    return
    DIVIDE(_Open,[YTD Sales])

     

    And put it in a table visual, the result like this.

     

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

     

    Best regards,

     

    Community Support Team _ zhenbw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    BTW, pbix as attached.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the suggestions, found the solution in the meanwhile.

       

      Adding a calculation around the divide formula gave the desired result.