cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tad17
Solution Sage
Solution Sage

Expressions that yield variant data-type cannot be used to define calculated columns.

Hey Guys
 
BIZ DATE = if(and(Format([ATD],"")=blank(),format([BIZ DAYS],"")=blank()),"",
var dateidx = calculate( max('Calendar'[WorkingDayIndex] ) , 'P FILES'[ATD] = RELATED('Calendar'[Date] ) )
var newdateidx = dateidx + 'P FILES'[BIZ DAYS]

 

return
calculate(
max('Calendar'[Date]),
filter(
ALL('Calendar'),
'Calendar'[WorkingDayIndex] = newdateidx
&& 'Calendar'[IsWorkDay] = 1
)
)
)
 
Data is company sensetive.
 
I found a forum that suggested creating a calendar table to add days to a date and that seems to work (everything after the first line). However, the if statement will not seem to work. I understand that I am looking at two columns with different formatting (one is date and the other is text) I have tried using several combinations of value and format functions to no avail. I cannot change the formatting of these columns as their formatting is necessary for other calculated columns. I have tried making helper columns a little, but haven't had much luck.
 
Also, the ATD column, which is date format, has blanks (null) in it.
 
Any suggestions are appreciated.
 
-Tad
1 REPLY 1
sturlaws
Super User
Super User

Hi @Tad17,

what is your desired outcome when 'P FILES'[ATD] and 'P FILES'[BIZ DAYS] are both blank? Because as it is written now, dateidx does not get a value when they are both blank.

 

You could try something like this

BIZ DATE =
VAR dateidx =
    IF (
        AND ( ISBLANK ( [ATD] ), ISBLANK ( [BIZ DAYS] ) ),
        BLANK (),
        CALCULATE (
            MAX ( 'Calendar'[WorkingDayIndex] ),
            'P FILES'[ATD] = RELATED ( 'Calendar'[Date] )
        )
    )
VAR newdateidx = dateidx + 'P FILES'[BIZ DAYS]
RETURN
    CALCULATE (
        MAX ( 'Calendar'[Date] ),
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[WorkingDayIndex] = newdateidx
                && 'Calendar'[IsWorkDay] = 1
        )
    )



 

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors