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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
CP0822
New Member

Problem with If and Blank()

Hi,

 

I have a formula created using DAX in my table but something is not Ok with the final result and i don't know why.

 

I have this Column that cames from an Excel file, info inside was input with a PowerApps app. But the second column was added in PowerBi

 

This is basically the formula that I'm using

 

Consump_time = IF(Table1[Consumption_pre_status]="Pend",BLANK(),Table1[Latest Consump date]-Table1[Contract_date])-2*(ROUNDDOWN((Table1[Latest Consump date].[Date]-Table1[Contract_date])/7,0))
 
So I expect "Blank" if the value on the first column is "Pend" but I'm getting anything else but no a blank value. Do you have any idea?
 

Column from datebase

PB-1.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Calculated column

Image2bi.jpg

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@CP0822 

I have tested with some of my files.

With my experience, try check whether there is spaces after the text e.g. "Pend ", I have met that a few times.

 

Paul Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

MFelix
Super User
Super User

Hi @CP0822,

You have the parênteses of the if clause in the incorrect place, you are closing the IF clause before the - 2.

Try this

 

Consump_time =
IF (
    Table1[Consumption_pre_status] = "Pend",
    BLANK (),
    ( Table1[Latest Consump date] - Table1[Contract_date] )
        - 2
            * (
                ROUNDDOWN (
                    ( Table1[Latest Consump date].[Date] - Table1[Contract_date] ) / 7,
                    0
                )
            )
)

 

As you can see on the image below this new calculation returns expected result.

consu.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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