Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
coding7
Frequent Visitor

Spread of total value across days

Hi, 

 

I've this dax measure:

 

 

Reserved Instances Daily Amortized Cost= 
VAR ContextDate = MAX ( 'Date'[Date] )
VAR CostStartDate = CALCULATE ( MIN ( 'Fact Partner Center Costs'[Charge Start] ), ALL ( 'Date' ) )
VAR CostEndDate = CALCULATE ( MAX ( 'Fact Partner Center Costs'[Charge End Date] ), ALL ( 'Date' ) )
VAR DailyAmortizedCost = MIN ('Fact Partner Center Costs'[Daily Amortized Cost])
VAR ReservedInstancesCost =
    CALCULATE (
        SUMX ( VALUES ( 'Date'[Day] ), DailyAmortizedCost ),
        ALL ( 'Date')
    )

RETURN
IF (
    ContextDate >= CostStartDate && ContextDate <= CostEndDate,
    ReservedInstancesCost,
    BLANK ()
)

 


which shows me the correct total for the specific month. The problem is the value needs to be divided by the number of days in the month and distributed to the remaining days. The sum of the days will be the total value.

So for this example:

coding7_0-1691586422603.png

 

the value will be 4.54 (140.64 / 31(number of days for July)) and the desired output will be:

YearMonthDayReserved Instances Daily Amortized Cost 
2023July14,54
2023July24,54
2023July34,54
2023July44,54
2023July54,54
2023July64,54
2023July74,54
2023July84,54
2023July94,54
2023July104,54
2023July114,54
2023July124,54
2023July134,54
2023July144,54
2023July154,54
2023July164,54
2023July174,54
2023July184,54
2023July194,54
2023July204,54
2023July214,54
2023July224,54
2023July234,54
2023July244,54
2023July254,54
2023July264,54
2023July274,54
2023July284,54
2023July294,54
2023July304,54
2023July314,54


Additionally I have a slicer with the contract key, and if I selected more than one it has to do the sum per day, that is, for contract_key = 10 the value is 4.54 and for contract_key = 20 the value is 4 , if I selected both at the same time, the value of the measure must be 8.54 and then do the respective sum of the total days.

ps: I showed only for July 2023 but the scenario is for more than one month and year

Thanks you !

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @coding7 ,

 

Here I create a sample to have a test.

vrzhoumsft_0-1692002326293.png

Reserved Instances Daily Amortized Cost = 
VAR _ADD =
    ADDCOLUMNS (
        'Calendar',
        "Value",
            DIVIDE (
                CALCULATE (
                    SUM ( 'Table'[Reserved Instances Cost] ),
                    FILTER (
                        'Table',
                        'Table'[Year] = EARLIER ( 'Calendar'[Year] )
                            && 'Table'[Month] = EARLIER ( 'Calendar'[Month] )
                    )
                ),
                MAXX (
                    ALLEXCEPT ( 'Calendar', 'Calendar'[Year], 'Calendar'[Month] ),
                    'Calendar'[Day]
                )
            )
    )
RETURN
    SUMX ( _ADD, [Value] )

Result is as below.

vrzhoumsft_1-1692002351518.png

 

Best Regards,
Rico Zhou

 

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

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @coding7 ,

 

Here I create a sample to have a test.

vrzhoumsft_0-1692002326293.png

Reserved Instances Daily Amortized Cost = 
VAR _ADD =
    ADDCOLUMNS (
        'Calendar',
        "Value",
            DIVIDE (
                CALCULATE (
                    SUM ( 'Table'[Reserved Instances Cost] ),
                    FILTER (
                        'Table',
                        'Table'[Year] = EARLIER ( 'Calendar'[Year] )
                            && 'Table'[Month] = EARLIER ( 'Calendar'[Month] )
                    )
                ),
                MAXX (
                    ALLEXCEPT ( 'Calendar', 'Calendar'[Year], 'Calendar'[Month] ),
                    'Calendar'[Day]
                )
            )
    )
RETURN
    SUMX ( _ADD, [Value] )

Result is as below.

vrzhoumsft_1-1692002351518.png

 

Best Regards,
Rico Zhou

 

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

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.