Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi, Below is my sample data and result needed, i am trying in calculated column but its giving count for each month , but not like i am expecting the result set.
Please help me with the DAX or Calculated column
I have Data Like This | |||
ID | StartDate | EndDate | |
1 | 5/1/2022 | 5/31/2022 | |
1 | 6/1/2022 | 6/30/2022 | |
1 | 10/1/2022 | 10/30/2022 | |
1 | 11/1/2022 | 11/30/2022 | |
1 | 11/1/2022 | 11/30/2022 | |
1 | 12/1/2022 | 12/31/2022 | |
1 | 12/1/2022 | 12/31/2022 | |
1 | 1/1/2023 | 1/31/2023 | |
Result needed | Month Year | Count | |
OCT 2022 | 3 | 5/1/2022 to 10/30/2022 | |
NOV-2022 | 5 | 5/1/2022 to 11/30/2022 | |
DEC-2022 | 7 | 5/1/2022 to 12/31/2022 | |
JAN-2023 | 8 | 5/1/2022 to 1/31/2023 |
Hi @vvv
you have to have a Date table minimum with Date and Year Month columns. The you can use
Count =
SUMX (
VALUES ( 'Date'[Year Month] ),
CALCULATE (
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR MinDate =
MIN ( 'Date'[Date] )
RETURN
COUNTROWS (
FILTER ( 'Table', 'Table'[StartDate] <= MaxDate && 'Table'[EndDate] >= MinDate )
)
)
)
This are the two tables I use:
and this is the DAX code
_result =
VAR EOM = MAX(MonthYear[End of Month])
VAR _filter = FILTER(Transactions, Transactions[EndDate] <= EOM)
RETURN
COUNTROWS(_filter)
and this is the result:
@vvv Better Running Total - Microsoft Power BI Community
Hi,
I did this but , i am getting same count count for all Months
Oct 22 - 8
Nov -22 8
Dec 22 8
Am i missing anything
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
8 |