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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Measure: Calculate % of results that equal criteria within another table

Hi,

 

I need help creating a custom measure that will return the % of [Claim ID] that have a [Days Between] value equal to or less than the reference values in another table.  This percentage would need to calculate the percentage based on only that [Company] number of distinct [Claim ID].  I need the measure to by dynamic so that it calculates based on a Slicer's selection for that [Company]

 

Here is an example data set with the Claim Data:

Capture.PNG

Here is an example data set with the reference values:

Capture2.PNG

 

Given this example data, I would expect the measure to return a value of 50% when USA is selected from the slicer and 67% when Korea is selected. 

- USA should = 50% since 3 out of 6 distinct [Claim ID] had a [Days Between] value equal to or less than 30

- Korea should = 67% since 2 out of 3 distinct [Claim ID] had a [Days Between] value equal to or less than 20

 

Can you please assist me in creating this type of measure?

Thank you,

Andrew

3 ACCEPTED SOLUTIONS
littlemojopuppy
Community Champion
Community Champion

Hi @Anonymous 

 

Try this...

% Claims Better Than Goal = 
VAR ClaimSummary =
    ADDCOLUMNS(
        Claims,
        "DaysBetween",
        DATEDIFF(
            Claims[StartDate],
            Claims[EndDate],
            DAY
        ),
        "Goal",
        RELATED(Companies[Goal])
    )
VAR ClaimCount = COUNTROWS(ClaimSummary)
VAR ClaimsBeatingGoalCount =
    COUNTROWS(
        FILTER(
            ClaimSummary,
            [DaysBetween] <= [Goal]
        )
    )
RETURN

DIVIDE(
    ClaimsBeatingGoalCount,
    ClaimCount,
    BLANK()
)

littlemojopuppy_0-1646250965889.png

Hope this helps!

 

View solution in original post

PijushRoy
Super User
Super User

Hi, @Anonymous 

Create a calculated col in datatable

Goal = LOOKUPVALUE(RefrenceTable[Goal],RefrenceTable[Company],'DataTable'[Company])
 
Then use this formula
Measure = VAR _DistinctCountClaimID = CALCULATE(DISTINCTCOUNT('DataTable'[Claim ID]),ALLEXCEPT('DataTable','DataTable'[Company]))
VAR _days = SELECTEDVALUE('DataTable'[Goal])
VAR _dayscount = CALCULATE(COUNT('DataTable'[Company]), 'DataTable'[Days Between] <= _days)
RETURN
_dayscount/_DistinctCountClaimID
 
0pb1.JPG
 
 
If you have any question, please let me know.
If solve your requirement, please mark this answer as SOLUTION
If this comment helps you, please LIKE this comment/Kudos



Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





View solution in original post

@Anonymous if you change the data type from a duration to whole number you should be ok.  Worked with the pbix I attached.

View solution in original post

8 REPLIES 8
PijushRoy
Super User
Super User

Hi, @Anonymous 

Create a calculated col in datatable

Goal = LOOKUPVALUE(RefrenceTable[Goal],RefrenceTable[Company],'DataTable'[Company])
 
Then use this formula
Measure = VAR _DistinctCountClaimID = CALCULATE(DISTINCTCOUNT('DataTable'[Claim ID]),ALLEXCEPT('DataTable','DataTable'[Company]))
VAR _days = SELECTEDVALUE('DataTable'[Goal])
VAR _dayscount = CALCULATE(COUNT('DataTable'[Company]), 'DataTable'[Days Between] <= _days)
RETURN
_dayscount/_DistinctCountClaimID
 
0pb1.JPG
 
 
If you have any question, please let me know.
If solve your requirement, please mark this answer as SOLUTION
If this comment helps you, please LIKE this comment/Kudos



Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





littlemojopuppy
Community Champion
Community Champion

Hi @Anonymous 

 

Try this...

% Claims Better Than Goal = 
VAR ClaimSummary =
    ADDCOLUMNS(
        Claims,
        "DaysBetween",
        DATEDIFF(
            Claims[StartDate],
            Claims[EndDate],
            DAY
        ),
        "Goal",
        RELATED(Companies[Goal])
    )
VAR ClaimCount = COUNTROWS(ClaimSummary)
VAR ClaimsBeatingGoalCount =
    COUNTROWS(
        FILTER(
            ClaimSummary,
            [DaysBetween] <= [Goal]
        )
    )
RETURN

DIVIDE(
    ClaimsBeatingGoalCount,
    ClaimCount,
    BLANK()
)

littlemojopuppy_0-1646250965889.png

Hope this helps!

 

Anonymous
Not applicable

I tried this but the 

 

RELATED(Companies[Goal]) portion of the DAX gave me trouble.  My reference table has a numerical value set while the DATEDIFF is returning a interval of days.  So, the DAX isn't finding a similar data type.

 

How can I resolve this issue?

@Anonymous DATEDIFF returns the count of interval boundaries crossed between two dates: a numeric result.  It clearly works...

Could you share your pbix to try to figure this out?

Anonymous
Not applicable

I verified in Power Query that [Adjudicated Days] is set as a numerical value, table name = '

Adjudicated_PG_30'

Capture.PNG

 

Here is a screen grab of the DAX.  The RELATED ( Adjudicated_PG_30[Adjudicated Days] ) returns an error of "Parameter is not correct type" and it then cannot find the column name "Adjudicated Days"

@Anonymous you're trying to solve this in Power Query???  😯

Anonymous
Not applicable

Oh no.  I was just showing you that I confirmed in Power Query that 

Adjudicated_PG_30[Adjudicated Days] is a numerical value.
 
Capture1.PNG

@Anonymous if you change the data type from a duration to whole number you should be ok.  Worked with the pbix I attached.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 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.