Forum Discussion

Mangnuel's avatar
Mangnuel
Helper I
1 year ago
Solved

Monthly into Daily Resolution

Hey there Power Bi World,

I need your help.


Given is a tabel including three different informations.
The Asset, the Date and the Yield from the Asset.

 

monthly total for each asset is within the cell belonging to the first day of the month.
e.g  Asset A monthly Yield in Jan = 31,

We do need a table converting this monthly value into daily values.
Take the given monthly total and divde it by the amount of days from this month.

e.g Asset A  Daily Yield (Jan) =  mtlyYield (31) / Days in Jan (31) = 1


Let's see what happens, butterflies in my stomach.
Thanks in advance

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi  Mangnuel ,


    Are you referring to the start date and end date inside the CALENDAR() function?

    The parameters inside the CALENDAR() function can be customized to change, the date range is from the specified start date to the specified end date, including these two dates, if you want to use today as the last date inside the function, you can use the following dax.

    CALENDAR(
        DATE(2024,1,1),
        TODAY())

    Refer to:

    CALENDAR function (DAX) - DAX | Microsoft Learn

     

    Best Regards,

    Liu Yang

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

4 Replies

  • You use a Calendar table in your data model, and then you use VALUES(Calendar[Date]) to get the number of days for each month.  For example February 2024 was NOT 28 days...

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from lbendlin , please allow me to add some more information:
    Hi  Mangnuel ,

     

    Here are the steps you can follow:

    1. Create calculated table.

    Table 2 =
    var _datetable=
    CALENDAR(
        DATE(2024,1,1),
        DATE(2024,3,31))
    var _assettable=
    DISTINCT('Table'[Asset])
    var _addtable=
    CROSSJOIN(
        _assettable,_datetable)
    RETURN
    ADDCOLUMNS(
        _addtable,
        "Yield",
        DIVIDE(
        SUMX(
            FILTER(ALL('Table'),
            'Table'[Asset]=EARLIER([Asset])&&
            YEAR('Table'[Date])=YEAR(EARLIER([Date]))&&
            MONTH('Table'[Date])=MONTH(EARLIER([Date]))),
            [Yield]),
     DAY(EOMONTH([Date],0))))

    2. Result:

     

     

    Best Regards,

    Liu Yang

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

    • Mangnuel's avatar
      Mangnuel
      Helper I

      Hello Anonymous 

       

      so far it's looling good, thanks a lot.
      One question regarding the dates.
      Beginning and ending is a static value.
      Can the end by dynamic, something like today()....

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Mangnuel ,


    Are you referring to the start date and end date inside the CALENDAR() function?

    The parameters inside the CALENDAR() function can be customized to change, the date range is from the specified start date to the specified end date, including these two dates, if you want to use today as the last date inside the function, you can use the following dax.

    CALENDAR(
        DATE(2024,1,1),
        TODAY())

    Refer to:

    CALENDAR function (DAX) - DAX | Microsoft Learn

     

    Best Regards,

    Liu Yang

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