Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Always having problems with blank value.
i am trying to do a switch function, if the date value is blank "--"
if not, formula will do a datediff between 2 dates.
testing = switch(
TRUE,
ISBLANK(Policy[Final Concurrence Date]),"--",
NETWORKDAYS(Policy[Date_Assigned],Policy[Final Concurrence Date],1)
)
formula is calculating the datediff correctly, but having a hard time if the date is blank/null.
tried IF/else as well, both gave me this error
expressions that yield variant data-type cannot be used to define calculated columns
Those who are smarter than I please help. ty
Solved! Go to Solution.
Hi @nerdyplayer
the main issue is confliction of data type within the same column.
Hence to avoid this confliction I have converted the final value in string.
Please check the below snap
If this resolves your issue then please accept the same as your solution.
thank you all. it was indeed the conflicted between the dash. I did need for the dashes for another column and it was useful for me. thank you all again.
Hi @nerdyplayer
the main issue is confliction of data type within the same column.
Hence to avoid this confliction I have converted the final value in string.
Please check the below snap
If this resolves your issue then please accept the same as your solution.
Hi @nerdyplayer ,
I create a table as you mentioned.
When I use your DAX code in a calculated column, it gives me the same error.
The error you’re encountering is due to the fact that calculated columns in DAX cannot return different data types. In your case, the SWITCH function is trying to return both a string (“–”) and a number (result of NETWORKDAYS), which is causing the issue.
If you still want to use calculated column, you can use this DAX code.
Column =
SWITCH (
TRUE,
ISBLANK ( Policy[Final Concurrence Date] ), 0,
NETWORKDAYS ( Policy[Date_Assigned], Policy[Final Concurrence Date], 1 )
)
If you want to still use "--", I think you can use Measure, here is the DAX code.
testing =
SWITCH (
TRUE,
ISBLANK ( MAX('Policy'[Final Concurrence Date]) ), "--",
NETWORKDAYS ( MAX('Policy'[Date_Assigned]), MAX('Policy'[Final Concurrence Date]), 1 )
)
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
networkdays returns an integer, the other path returns a text string. You can't have those options in a SWITCH/IF. You have to return the same type from all paths
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
9 |