Forum Discussion

Brianoreilly's avatar
Brianoreilly
Icon for Helper II rankHelper II
7 years ago

Calculated Column: If Statement with Date Slicer

Hi Folks, 

 

I have 3 tables: 

1: Timecard Table

2: Date Table 

3: Contact Table. 

 

I am hoping to build a Calculated Column (not a measure). 

 

The logic I require is if the: Resources Start Date and End Date are blank  then pull the minimum date selected in the date table slicer. 

It is currently pulling the minimum date in the entire table.

 

Any help appreciated.

 

Issue with the code in red. How can I get to slicer value instead of the table minimum value.

 

 

Test = 
VAR startdate =
    
        CALCULATE (
            VALUES ( Contact[Start Date] ),
            FILTER ( Contact, Contact[Id] = 'Timecard Split'[Resource ID] )
        )
    

VAR enddate =
    
        CALCULATE (
            VALUES(Contact[Start Date]),
            FILTER ( Contact, Contact[Id] = 'Timecard Split'[Resource ID] )
        )
    

RETURN
    (IF(And(ISBLANK(startdate),ISBLANK(enddate)),[Minimum Date],startdate))

 

1 Reply

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    hi, Brianoreilly

    You said "I am hoping to build a Calculated Column (not a measure)."

     calculated columns and calculated  tables are not affected by any slicer.

    https://community.powerbi.com/t5/Desktop/New-table-with-measures-values/td-p/189124

     

     calculated columns and calculated  tables are only "computed during database processing(e.g. data refresh) and then stored in the model, they do not response to user selections on the report(like a Slicer)."

     

    So if you want the slicer can affect the values, you need to build a Calculated measure (not a column).

     

    Best Regards,

    Lin