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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
jk_adelaide
Frequent Visitor

open Claims monthly count

Hi,

I want to count the open claims from the below table. Any claims not closed will carry to the next month as open.

i used the below measure but not giving accurate data.

Total open Claims = CALCULATE(COUNT('Claims'[Claims ID]),FILTER('Claims','Claims'[Created]<=ENDOFMONTH('Date'[Date]) && 'Claims'[Closed]>=ENDOFMONTH('Date'[Date])))
i have created a inactive relationship with date table with Claims Created and Closed.
Claims IDCreatedClosed
190926094828/09/202217/05/2023
190927150017/10/202228/03/2023
190928104527/10/202228/03/2023
190929133903/11/202228/03/2023
190908110813/12/202203/02/2023
190908132321/12/202217/02/2023
190908112322/02/202330/05/2023
190810121830/03/202303/04/2023
190811081714/04/202319/05/2023
190811085215/05/202319/05/2023
190812100715/05/202312/07/2023
190817102105/06/202315/06/2023
191708122305/06/202315/06/2023
190817181106/06/202315/06/2023
190923181212/06/202315/06/2023
190928163912/06/202328/06/2023
190926114616/08/2023 

 

if you do a manual calculations it will be like below but measure gives different.  Thanks in advance.

Month Yearmanualmeasure
Jan-2366
Feb-2374
Mar-2362
Apr-2342
May-2351
Jun-2361
Jul-231no value
Aug-231no value
2 ACCEPTED SOLUTIONS
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26Rimc1BFjek33M-f9D?e=OAgThj

View solution in original post

Ahmedx
Super User
Super User

1) create calendar table

Calendar = VAR BaseCalendar =
    CALENDAR ( DATE ( 2022, 1, 1 ), DATE (2023, 12, 31 )) 
  
RETURN
    GENERATE (
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR YearDate = YEAR ( BaseDate )
        VAR MonthNumber = MONTH ( BaseDate )
        VAR YearMonthNumber = YearDate * 12 + MonthNumber - 1
        RETURN ROW (
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT ( BaseDate, "mmmm"),
            "Year Month Number", YearMonthNumber,
            "Year Month", FORMAT ( BaseDate, "mmm yy")
        )
    )

Screenshot_1.png

2) measure

count the open claims = 
VAR _GenaretDateBetWeen = 
       GENERATE (
                'Claims',
                DATESBETWEEN (
                    'Calendar'[Date],
                    'Claims'[Created],
                    IF ( ISBLANK ( 'Claims'[Closed] ), 'Claims'[Created], 'Claims'[Closed] )
                ))

VAR _SelectColumns_And_Distinct = 
 DISTINCT(SELECTCOLUMNS(_GenaretDateBetWeen,
                "Claims ID",[Claims ID] ,
                "@Month_Year",FORMAT ([Date], "mmm yy")))
VAR _SelectOnlydateCoumns=   
              SELECTCOLUMNS(_SelectColumns_And_Distinct,"@Month_Year",[@Month_Year])

VAR _INTERSECT =
         INTERSECT(_SelectOnlydateCoumns,VALUES('Calendar'[Year Month]))

RETURN  
COUNTROWS(_INTERSECT)

Screenshot_2.pngScreenshot_3.png

 

 

 

View solution in original post

5 REPLIES 5
Ahmedx
Super User
Super User

Screenshot_4.png

Ahmedx
Super User
Super User

1) create calendar table

Calendar = VAR BaseCalendar =
    CALENDAR ( DATE ( 2022, 1, 1 ), DATE (2023, 12, 31 )) 
  
RETURN
    GENERATE (
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR YearDate = YEAR ( BaseDate )
        VAR MonthNumber = MONTH ( BaseDate )
        VAR YearMonthNumber = YearDate * 12 + MonthNumber - 1
        RETURN ROW (
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT ( BaseDate, "mmmm"),
            "Year Month Number", YearMonthNumber,
            "Year Month", FORMAT ( BaseDate, "mmm yy")
        )
    )

Screenshot_1.png

2) measure

count the open claims = 
VAR _GenaretDateBetWeen = 
       GENERATE (
                'Claims',
                DATESBETWEEN (
                    'Calendar'[Date],
                    'Claims'[Created],
                    IF ( ISBLANK ( 'Claims'[Closed] ), 'Claims'[Created], 'Claims'[Closed] )
                ))

VAR _SelectColumns_And_Distinct = 
 DISTINCT(SELECTCOLUMNS(_GenaretDateBetWeen,
                "Claims ID",[Claims ID] ,
                "@Month_Year",FORMAT ([Date], "mmm yy")))
VAR _SelectOnlydateCoumns=   
              SELECTCOLUMNS(_SelectColumns_And_Distinct,"@Month_Year",[@Month_Year])

VAR _INTERSECT =
         INTERSECT(_SelectOnlydateCoumns,VALUES('Calendar'[Year Month]))

RETURN  
COUNTROWS(_INTERSECT)

Screenshot_2.pngScreenshot_3.png

 

 

 

Thanks Ahmedx, appriciated.👍

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26Rimc1BFjek33M-f9D?e=OAgThj

Hi Ahmedx,

thanks but i can't open this with my version of power bi. 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.