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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Allocation of Amount into its week using start and end booking date.

I have amounts. A start date and an end date.

I want to allocate the amounts into their weeks (red cells)

I can do this in excel using if statements. Can we do this in Power BI?

 

Thanks Team

sssss.PNG

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create two calculated tables

One is "date" table

date = ADDCOLUMNS(CALENDARAUTO(),"year",YEAR([Date]),"week",WEEKNUM([Date],1))

Add a caluclated column in this table

weeknum = CALCULATE(MIN([Date]),ALLEXCEPT('date','date'[year],'date'[week]))

Another table 

Table 2 =
FILTER (
    CROSSJOIN (
        'Table',
        FILTER (
            'date',
            'date'[Date] <= CALCULATE ( MAX ( 'Table'[end date] ), ALL ( 'Table' ) )
                && 'date'[Date] >= CALCULATE ( MIN ( 'Table'[start date] ), ALL ( 'Table' ) )
        )
    ),
    [Date] >= [start date]
        && [Date] <= [end date]
)

Create a measure in this table

Measure = CALCULATE(SUM('Table 2'[amount per day]),ALLEXCEPT('Table 2','Table 2'[prepayment],'Table 2'[year],'Table 2'[weeknum]))

Capture1.JPGCapture2.JPGCapture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create two calculated tables

One is "date" table

date = ADDCOLUMNS(CALENDARAUTO(),"year",YEAR([Date]),"week",WEEKNUM([Date],1))

Add a caluclated column in this table

weeknum = CALCULATE(MIN([Date]),ALLEXCEPT('date','date'[year],'date'[week]))

Another table 

Table 2 =
FILTER (
    CROSSJOIN (
        'Table',
        FILTER (
            'date',
            'date'[Date] <= CALCULATE ( MAX ( 'Table'[end date] ), ALL ( 'Table' ) )
                && 'date'[Date] >= CALCULATE ( MIN ( 'Table'[start date] ), ALL ( 'Table' ) )
        )
    ),
    [Date] >= [start date]
        && [Date] <= [end date]
)

Create a measure in this table

Measure = CALCULATE(SUM('Table 2'[amount per day]),ALLEXCEPT('Table 2','Table 2'[prepayment],'Table 2'[year],'Table 2'[weeknum]))

Capture1.JPGCapture2.JPGCapture3.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks Maggie! You are so smart, it works!

 

I've seen your responses on other things i have searched up and all have been so good. How did you get so smart?

 

But just a query, what is the purpose of the measure? Couldn't I still produce the same matrix without using measure but instead amount per day?

v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

In Power BI, we need to create another table, it would be static, would you like this method?

 

Best Regards
Maggie

Anonymous
Not applicable

That would be good. Just as long as we can acheive the same output.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.