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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hrafnkel11
Helper I
Helper I

Calculated Column Ignoring Slicer Selection

Happy Friday!

 

I am having issues with a calculated column where I have a people table and need to bring in the total passed tests for each person from another table. I’m trying to do this as a calculated column, because there are multiple types of tests and I need to run a conditional column across them to determine final results for each person.

 

The complication I am having is that the person table is a snapshot that has one person record per “as of date”. Because of this, I have one date table governing the people and a separate date table governing the tests (since when someone took a test is irrespective of which “as of date” someone chooses). I need a user to be able to choose the as of date for the people population, as well as the date range for when tests were completed.

 

This is the calculated column I’m having trouble adding to the PERSON table. I’ve tried multiple versions of this and either get ALL tests regardless of which test date is selected or in the case of the below, I get partial data (very limited number of records, all correct, but everything else blank).

 

I feel like I’m missing something elementary here, so any help would be massively appreciated. Thanks!

 

 

 

_Test_Type_1_Passes = 
var _startdate = min('TEST DATE'[DATE])
var _enddate = max('TEST DATE'[DATE])
return
CALCULATE(
    COUNTROWS(
        FILTER('Test Data',
        'Test Data'[Result]="Pass" &&
        'Test Data'[Type]= "1" &&
        selectedvalue('Test Data'[Date]) >= _startdate && 
        selectedvalue('Test Data'[Date]) <= _enddate
    )))

 

 

 

I have a feeling it's due to how my model is set up, but I hesitate changing it if possible, since this is part of a much wider report. Here's a simplified model:

 

hrafnkel11_0-1679066764780.png

 

Expected result in person table:

PersonTest_Type_1_PassesTest_Type_2_PassesTest_Type_3_Passes
John301
Sally521
Anders100
1 ACCEPTED SOLUTION
hrafnkel11
Helper I
Helper I

Update: I've gotten this to work by abandoning the calculated column and just using a measure. I feel like this is usually the answer every time I have a problem with a calculated column.

View solution in original post

1 REPLY 1
hrafnkel11
Helper I
Helper I

Update: I've gotten this to work by abandoning the calculated column and just using a measure. I feel like this is usually the answer every time I have a problem with a calculated column.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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