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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
dbollini
Helper II
Helper II

Measure to count distinct values as 1 over certain period of time range

Hello,

 

I am trying to calculate the Distinct count of Colonoscopies for individual patients and i am having couple of issues below is the sample data:

1)Below is the measure i am using to get distinct count but now My measure has to calculate  and include the logic to “bundle” records that are within the same 72 hour range as 1 count and then distinict count of colon with start date or health plan id whichever user requests.

 

Colonoscopies = CALCULATE( DISTINCTCOUNT(Paid_View[Health Plan ID]), FILTER(Paid_View,Paid_View[DX_COLONO]="Colonoscopy"))
 

2)There is a drill through page which i created for this counts but in that drill through report it is showing all the patients in the list though the patient woth Dx_colono= colonscopy should only show but it shows office visits and all patients.

 

COUNTYDXDX_COLONOStart DateHealth Plan IDMember Name
Fort Bendnullnull4/10/2015 12:00:00 AM123456Joe,D
Fort Bendnullnull4/10/2015 12:00:00 AM123456John,D
Fort Bendnullnull4/10/2015 12:00:00 AM12356John,C
Fort BendnullColonoscopy4/21/2015 12:00:00 AM12456David,C
Fort Bendnullnull4/21/2015 12:00:00 AM12345David,F
Fort Bendnullnull4/21/2015 12:00:00 AM123456Carol,C

 

Can someone help me with the correct measure and Drill through issue too thanks

1 ACCEPTED SOLUTION

HI @dbollini,

You can modify the variable to use CALCULATETABLE function, then it can be compared with in operator:

formula =
VAR currDate =
    MAX ( Paid_View[Start Date] )
VAR planlist =
    CALCULATETABLE (
        VALUES ( Paid_View[Health Plan ID] ),
        FILTER ( Paid_View, Paid_View[DX_COLONO] = "Colonoscopy" )
    )
RETURN
    CALCULATE (
        COUNT ( Paid_View[Health Plan ID] ),
        FILTER (
            ALLSELECTED ( Paid_View ),
            [Health Plan ID]
                IN planlist
                    && [Start Date] >= currDate - 3
                    && [Start Date] <= currDate + 3
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

7 REPLIES 7
v-shex-msft
Community Support
Community Support

Hi @dbollini ,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hello,

 

Please find the .pbix file in the link below with some test data and please request so i can approve access thanks

 

https://www.dropbox.com/scl/fo/itl74m733kuqazj98tfjm/h?rlkey=fafzz5m81oojmwm89ngtiox3c&dl=0

HI @dbollini,

You can try to use the following measure formula to get the count of records that include in the records 72 hour ranges:

formula =
VAR currDate =
    MAX ( Paid_View[Start Date] )
VAR planlist =
    CALCULATE (
        VALUES ( Paid_View[Health Plan ID] ),
        FILTER ( Paid_View, Paid_View[DX_COLONO] = "Colonoscopy" )
    )
RETURN
    CALCULATE (
        COUNT ( Paid_View[Health Plan ID] ),
        FILTER (
            ALLSELECTED ( Paid_View ),
            [Health Plan ID]
                IN planlist
                    && [Start Date] >= currDate - 3
                    && [Start Date] <= currDate + 3
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you and i tried this formual but it throws an error like The function expects a table expression for arguement ",but a string numeric expression was used and highlights below and says incorrect

 IN planlist

 

dbollini_0-1709139646990.png

I am getting Error below when i am using the code and i trie dto modify with other stuff but same error

HI @dbollini,

You can modify the variable to use CALCULATETABLE function, then it can be compared with in operator:

formula =
VAR currDate =
    MAX ( Paid_View[Start Date] )
VAR planlist =
    CALCULATETABLE (
        VALUES ( Paid_View[Health Plan ID] ),
        FILTER ( Paid_View, Paid_View[DX_COLONO] = "Colonoscopy" )
    )
RETURN
    CALCULATE (
        COUNT ( Paid_View[Health Plan ID] ),
        FILTER (
            ALLSELECTED ( Paid_View ),
            [Health Plan ID]
                IN planlist
                    && [Start Date] >= currDate - 3
                    && [Start Date] <= currDate + 3
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you for your help !

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.