cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hrafnkel11
Frequent Visitor

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
Frequent Visitor

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
Frequent Visitor

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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors