Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
@ links to members, content
I am trying to create a calculation in my table/matrix but cannot get it to work. I need to be able to do the following:
1. # of accounts per office that do not have a monthly premium or monthly revenue based on the effective date and this needs to be by day.
2. The date will have to be dynamic as new data comes in the dates will change.
3. I need a filter by year, month and quarter
Here is my data. I have also attached the pbix file
Office | Year | Quarter | Month | Day | #Accounts | First Monthly Revenue | Monthly Premium |
a | 2021 | Qtr 1 | January | 1 | 623 | 0 | 25471103.87 |
a | 2021 | Qtr 1 | January | 2 | 1 | 635 | 117682.38 |
a | 2021 | Qtr 1 | February | 1 | 10 | 101.334 | 51420.96 |
a | 2021 | Qtr 1 | March | 1 | 25 | 106.26 | 214084.0644 |
a | 2021 | Qtr 2 | April | 1 | 21 | 0 | 597595.9249 |
a | 2021 | Qtr 2 | April | 15 | 2 | 142.66 | 1518.24 |
a | 2021 | Qtr 2 | May | 1 | 40 | 0 | 186171.6251 |
a | 2021 | Qtr 2 | June | 1 | 25 | 0 | 602502.395 |
a | 2021 | Qtr 3 | July | 1 | 50 | 0 | 703467.6209 |
a | 2021 | Qtr 3 | August | 1 | 39 | 0 | 424631.915 |
a | 2021 | Qtr 3 | September | 1 | 48 | 0 | 800442.3436 |
a | 2021 | Qtr 4 | October | 1 | 18 | 106.699 | 250470.5051 |
a | 2021 | Qtr 4 | November | 1 | 19 | 154.983 | 77939.8981 |
a | 2021 | Qtr 4 | December | 1 | 29 | 103.1238 | 160952.7321 |
b | 2021 | Qtr 1 | January | 1 | 104 | 0 | 320159.71 |
b | 2021 | Qtr 1 | January | 15 | 4 | 10.19948 | 3236.57 |
b | 2021 | Qtr 1 | February | 1 | 18 | 0 | 30137.69 |
b | 2021 | Qtr 1 | March | 1 | 10 | 121.64 | 21878.68 |
b | 2021 | Qtr 1 | March | 15 | 1 | 4.83 | 32.2 |
b | 2021 | Qtr 2 | April | 1 | 24 | 1 | 52152.67 |
b | 2021 | Qtr 2 | April | 15 | 1 | 2.76 | 55.27 |
b | 2021 | Qtr 2 | May | 1 | 31 | 10.6755 | 156967.902 |
b | 2021 | Qtr 2 | May | 15 | 1 | 265.9095 | 5318.19 |
b | 2021 | Qtr 2 | June | 1 | 24 | 0 | 183073.72 |
b | 2021 | Qtr 2 | June | 15 | 4 | 167.807 | 6943.24 |
b | 2021 | Qtr 3 | July | 1 | 25 | 100.08 | 144132.84 |
b | 2021 | Qtr 3 | July | 15 | 1 | 29.988 | 705.6 |
b | 2021 | Qtr 3 | July | 25 | 1 | 5.193 | 51.93 |
b | 2021 | Qtr 3 | August | 1 | 22 | 10.625 | 49404.38 |
b | 2021 | Qtr 3 | September | 1 | 18 | 106.167 | 30897.91 |
b | 2021 | Qtr 4 | October | 1 | 43 | 0 | 176298.83 |
b | 2021 | Qtr 4 | October | 15 | 2 | 252.10023 | 6018.12 |
b | 2021 | Qtr 4 | November | 1 | 7 | 182.45548 | 13131.95 |
b | 2021 | Qtr 4 | November | 15 | 2 | 3.73 | 1215.56 |
b | 2021 | Qtr 4 | December | 1 | 18 | 107.63685 | 60358.72 |
c | 2021 | Qtr 1 | January | 1 | 1286 | 0 | 26637748.19 |
c | 2021 | Qtr 1 | January | 2 | 1 | 26.427 | 264.27 |
c | 2021 | Qtr 1 | January | 3 | 1 | 132.84 | 885.6 |
c | 2021 | Qtr 1 | January | 20 | 1 | ||
c | 2021 | Qtr 1 | February | 1 | 89 | 0 | 855855.42 |
c | 2021 | Qtr 1 | February | 11 | 2 | 288.5 | |
c | 2021 | Qtr 1 | February | 20 | 1 | 0 | 336.87 |
c | 2021 | Qtr 1 | March | 1 | 50 | 0 | 214722.26 |
c | 2021 | Qtr 1 | March | 2 | 1 | 400 | 0 |
c | 2021 | Qtr 1 | March | 26 | 1 | Net | 40987.02 |
c | 2021 | Qtr 2 | April | 1 | 103 | 0 | 1691212.986 |
c | 2021 | Qtr 2 | April | 2 | 2 | 23.342 | 42762.67 |
c | 2021 | Qtr 2 | April | 3 | 1 | 0 | 0 |
c | 2021 | Qtr 2 | April | 15 | 1 | 0 | |
c | 2021 | Qtr 2 | April | 30 | 1 | ||
c | 2021 | Qtr 2 | May | 1 | 83 | 0 | 581586.9402 |
c | 2021 | Qtr 2 | June | 1 | 158 | 0 | 884514.284 |
c | 2021 | Qtr 2 | June | 8 | 1 | 0 | |
c | 2021 | Qtr 2 | June | 9 | 1 | 2.83083 | 0 |
c | 2021 | Qtr 2 | June | 15 | 1 | 0 | |
c | 2021 | Qtr 3 | July | 1 | 105 | 0 | 797416.5322 |
c | 2021 | Qtr 3 | July | 2 | 1 | 71.4 | 1428 |
c | 2021 | Qtr 3 | August | 1 | 55 | 0 | 754956.2737 |
c | 2021 | Qtr 3 | September | 1 | 86 | 0 | 669460.0746 |
c | 2021 | Qtr 3 | September | 28 | 1 | 358.75 | 14369 |
c | 2021 | Qtr 4 | October | 1 | 106 | 0 | 4006931.365 |
c | 2021 | Qtr 4 | October | 12 | 1 | 0 | 0 |
c | 2021 | Qtr 4 | October | 31 | 1 | 0 | |
c | 2021 | Qtr 4 | November | 1 | 67 | 0 | 935427.1776 |
c | 2021 | Qtr 4 | December | 1 | 166 | 0 | 1692949.315 |
c | 2021 | Qtr 1 | January | 1 | 9 | 0 | 1572.1 |
c | 2021 | Qtr 2 | April | 1 | 1 | 0 | 0 |
c | 2021 | Qtr 2 | May | 1 | 2 | 18.06667 | 130.09 |
c | 2021 | Qtr 2 | June | 1 | 1 | 0 | |
c | 2021 | Qtr 3 | July | 1 | 1 | 0 | 0 |
c | 2021 | Qtr 3 | September | 1 | 1 | 0 | 0 |
d | 2021 | Qtr 1 | January | 1 | 25 | 0 | 51118.58 |
d | 2021 | Qtr 1 | March | 1 | 13 | 0 | 46302.23672 |
d | 2021 | Qtr 2 | April | 1 | 15 | 0 | 98940.9 |
d | 2021 | Qtr 2 | June | 1 | 6 | 10 | 4994.91 |
d | 2021 | Qtr 3 | July | 1 | 22 | 0 | 43445.6175 |
d | 2021 | Qtr 3 | August | 1 | 12 | 0.288 | 22674.77 |
d | 2021 | Qtr 3 | September | 1 | 89 | 0 | 496045.3088 |
d | 2021 | Qtr 4 | October | 1 | 11 | 0 | 17341.8354 |
d | 2021 | Qtr 4 | November | 1 | 19 | 0 | 18841.76 |
d | 2021 | Qtr 4 | December | 1 | 12 | 0 | 9609.3513 |
Solved! Go to Solution.
I'm having trouble understanding the tie between the answer key and the data but would something like this help provided you have a source column for when the accounts activate and leave?? I'm assuming you have date table. ****[see sample at bottom called dimdate]
Accounts Active=
VAR _startofperiod = MIN ( DimDate[Date] )
VAR _endofperiod = MAX ( DimDate[Date] )
VAR _threshold = sum(//revenue column goes here//)
RETURN
CALCULATE ( sum( Table1[#Accounts] ),
Table1[//DateAdded//] <= _endofperiod,
Table1[//revenue//]>=_thresholddate,
Table1[//DateInactive//] > _endofperiod)
),
REMOVEFILTERS ( DimDate )
)
DimDate =
VAR MINYEAR = 2008 //or some other min year
VAR MAXYEAR = 2021
VAR _DateTable =
ADDCOLUMNS (
FILTER (
CALENDARAUTO( ),
AND ( YEAR ( [DATE] ) >= MINYEAR, YEAR ( [DATE] ) <= MAXYEAR )
),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYYMM" ),
"YearMonthtext", FORMAT ( [Date], "YYYYMM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "QTR-" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ),
"YearQuarterNumber", Year([Date])*4 + QUARTER([Date]),
"HalfYear", YEAR([Date])&" H"&ROUNDUP(MONTH([Date])/6,0),
"LastImport", max(Table2[Max Date])
)
RETURN
_DateTable
Hi @evest ,
It's hard to achieve the look you want in the matrix. I have tried another way, please see if it helps.
Create measures.
Year_2021 = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[date].[Year]=SELECTEDVALUE('Table'[date].[Year])))
month_1 = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[date].[MonthNo]=SELECTEDVALUE('Table'[date].[MonthNo])))
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This works but now it wont show my previous months value. Here is my dax
I'm having trouble understanding the tie between the answer key and the data but would something like this help provided you have a source column for when the accounts activate and leave?? I'm assuming you have date table. ****[see sample at bottom called dimdate]
Accounts Active=
VAR _startofperiod = MIN ( DimDate[Date] )
VAR _endofperiod = MAX ( DimDate[Date] )
VAR _threshold = sum(//revenue column goes here//)
RETURN
CALCULATE ( sum( Table1[#Accounts] ),
Table1[//DateAdded//] <= _endofperiod,
Table1[//revenue//]>=_thresholddate,
Table1[//DateInactive//] > _endofperiod)
),
REMOVEFILTERS ( DimDate )
)
DimDate =
VAR MINYEAR = 2008 //or some other min year
VAR MAXYEAR = 2021
VAR _DateTable =
ADDCOLUMNS (
FILTER (
CALENDARAUTO( ),
AND ( YEAR ( [DATE] ) >= MINYEAR, YEAR ( [DATE] ) <= MAXYEAR )
),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYYMM" ),
"YearMonthtext", FORMAT ( [Date], "YYYYMM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "QTR-" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ),
"YearQuarterNumber", Year([Date])*4 + QUARTER([Date]),
"HalfYear", YEAR([Date])&" H"&ROUNDUP(MONTH([Date])/6,0),
"LastImport", max(Table2[Max Date])
)
RETURN
_DateTable
Charles thanks for the calendar table. It helped a lot. But now I am having trouble getting the previous month percentages to show. This is what the matrix should display in red. There is no prior month to December, therefore it will be blank but January should show December values. Any help would be appreciated. Here is my dax formula
I am dividing the number of plans by commission amount
Office | #Plans | Commission | Report Date | Current Percent | Previous Percent |
ABC | 15 | 768543 | Dec | 1.95% | 0.0% |
ABC | 8 | 85432 | Jan | 9.36% | 1.95% |
DEF | 405 | 14654 | Dec | .027% | |
DEF | 43 | 3194 | Jan | 23% | .027% |
Aha - I'd recommend connecting the date table to the date you are using in the table of commission calcs and then using either previousmonth() or this
So -- for current period
Hi @evest ,
Unfortunately, there's no way to automatically create measures in Power BI.
You can submit an idea for it at https://ideas.powerbi.com/forums and wait for users with the same needs as you to vote for you to help make it happen as soon as possible.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I did not get a solution from this forum. So I will rephrase my question. What I need to show in the matrix is pre aggregation for the year 2021 and monthly totals for 2022. This is simple to do in other reporting tools why is it so hard to do in Power BI
Total for entire 2021 | 2022 | |
January | Feburary | |
123,690 | 150 | 678 |
Hi @evest ,
It's hard to achieve the look you want in the matrix. I have tried another way, please see if it helps.
Create measures.
Year_2021 = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[date].[Year]=SELECTEDVALUE('Table'[date].[Year])))
month_1 = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[date].[MonthNo]=SELECTEDVALUE('Table'[date].[MonthNo])))
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This works but now it wont show my previous months value. Here is my dax
Hi @evest ,
Please have a try.
Create a column firstly.
Month_c = TOTALMTD(MAX('Table'[date].[MonthNo]),'Table'[date],FILTER(ALL('Table'),[Date].[MonthNo]=EARLIER('Table'[date].[MonthNo])))
Then create a measure.
sum_ = CALCULATE(SUM('Table'[First Monthly Revenue]),FILTER(ALL('Table'),'Table'[Month_c]<=SELECTEDVALUE('Table'[Month_c])&&'Table'[date].[Year]=SELECTEDVALUE('Table'[date].[Year])))
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Can you share an example of what (1) would look like?
I did not get a solution from this forum. So I will rephrase my question. What I need to show in the matrix is pre aggregation for the year 2021 and monthly totals for 2022.
Total for entire 2021 | 2022 | |
January | Feburary | |
123,690 | 150 | 678 |
This is what it should look like. The totals will include each day of the month where the day is missing monthly revenue and monthly premium in these columns the value is 0 or null. This is for 2021 but when I run the report the dates should adjust to 2022 dates. The dates you are looking at are the dates the report is run for that month.
Office | Count as of 1/11/2021 | Count as of 2/25/2021 | Count as of 3/8/2021 | Count as of4/27/2021 | Count as of 5/10/2021 | Count as of6/23/2021 | Count as of7/12/2021 | Count as of 8/19/2021 | Count as of 9/15/2021 | Count as of 11/18/2021 | Count as of 12/14/2021 |
a | 30 | 46 | 35 | 22 | 23 | 20 | 22 | 32 | 27 | 27 | 38 |
b | 6 | 6 | 0 | 7 | 5 | 8 | 1 | 1 | 0 | 2 | 3 |
c | 264 | 134 | 113 | 108 | 113 | 83 | 41 | 37 | 51 | 76 | 122 |
d | 52 | 52 | 51 | 53 | |||||||
e | 37 | 34 | 31 | 38 | 30 | 39 | 39 | 36 | 90 | 43 | 44 |
f | 31 | 19 | 19 | 20 | 21 | 23 | 22 | 21 | 21 | 24 | 25 |
g | 2 | 0 | 1 | 8 | 0 | 6 | 6 | 9 | 11 | 26 | 21 |
h | 14 | 14 | 11 | 13 | 17 | 21 | 12 | 14 | 11 | 20 | 25 |
i | 30 | 30 | 29 | 24 | 25 | 25 | 28 | 29 | 36 | 35 | 36 |
j | 8 | 6 | 2 | 18 | 4 | 5 | 4 | 1 | 1 | 3 | 1 |
k | 66 | 58 | 59 | 74 | 78 | 62 | 61 | 74 | 74 | 63 | 91 |
l | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 | 3 | 3 | 3 |
m | 29 | 59 | 37 | 59 | 71 | 64 | 57 | 69 | 77 | 73 | 153 |
n | 5 | 5 | 5 | 7 | 7 | 7 | 7 | 7 | 7 | 7 | 7 |
o | 4 | 7 | 6 | 8 | 24 | 7 | 11 | 16 | 14 | 22 | 11 |
p | 935 | 1283 | 1210 | 1235 | 1278 | 1266 | 1159 | 1206 | 1218 | 1210 | 1260 |
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.