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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.