Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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
Solved! Go to Solution.
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]))
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]))
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?
Hi @Anonymous
In Power BI, we need to create another table, it would be static, would you like this method?
Best Regards
Maggie
That would be good. Just as long as we can acheive the same output.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
85 | |
65 | |
51 | |
45 |
User | Count |
---|---|
217 | |
88 | |
81 | |
65 | |
56 |