March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Register NowGet certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
I have a measure in the syntax below to count the number of distinct activities (using another distinctcount measure) in the preceding 12 months from today's date. How might a measure like this be adapted to calculate this value at the end of any given month? For example, I would like to be able to create a bar chart visual by month where this count for the preceding 12 months is taken from the last date of the month.
Thank you!
12M Distinct Activity=
Solved! Go to Solution.
Hi @gambleave ,
You can create a [End of Month] column first.
The main table may have incomplete dates, so a calendar table is required.
Calendar = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))
End of Month = ENDOFMONTH('Calendar'[Date])
Then create a measure to count.
Count =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Activity ID] ),
FILTER (
ALL ( 'Table' ),
[Date] = [End of Month]
&& [YearMonth] = MAX ( 'Table'[YearMonth] )
)
)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @gambleave ,
You can create a [End of Month] column first.
The main table may have incomplete dates, so a calendar table is required.
Calendar = CALENDAR(DATE(2022,1,1),DATE(2022,12,31))
End of Month = ENDOFMONTH('Calendar'[Date])
Then create a measure to count.
Count =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Activity ID] ),
FILTER (
ALL ( 'Table' ),
[Date] = [End of Month]
&& [YearMonth] = MAX ( 'Table'[YearMonth] )
)
)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
118 | |
96 | |
82 | |
69 | |
61 |
User | Count |
---|---|
138 | |
115 | |
115 | |
99 | |
98 |