Reply
CW_85
New Member
Partially syndicated - Outbound

IF "text" than "formula"

Hello,

 

I've been using PowerBI for a while and now I want to add a formula to a column that shows the percentage of one amount (red lines) against the total amount (green lines). For this I entered this formula: Column = IF(ISTEXT(FIND("RFC",Facturatieoverzicht[Omschrijving])),Facturatieoverzicht[Bedrag]/SUM(Facturatieoverzicht[Bedrag])*100," ")

 

CW_85_0-1686056309391.png

 

The invoice text is described in the Description column. Everything that contains the text "RFC", he must apply the formula to, all other fields may remain empty. However, the above formula gives me the following error and I don't know how to solve it: You cannot use an expression that returns the Variant data type to define calculated columns.

 

I don't know what to do next, can somebody help me?

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Syndicated - Outbound

Hi @CW_85 ,

 

According to your statement, I know that you are creating a calculated column. As far as I know, there should be only one data type in Power BI Column.

Facturatieoverzicht[Bedrag]/SUM(Facturatieoverzicht[Bedrag])*100 will return number type value, however "" will return text type value. 

And I suggest you to try CONTAINSSTRING() function to check whether the value contains "RFC".

Calculated column:

Column =
IF (
    CONTAINSSTRING ( Facturatieoverzicht[Omschrijving], "RFC" ),
    Facturatieoverzicht[Bedrag] / SUM ( Facturatieoverzicht[Bedrag] ) * 100,
    BLANK ()
)

Result is as below.

vrzhoumsft_0-1686296479096.png

 

Best Regards,
Rico Zhou

 

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

 

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Syndicated - Outbound

Hi @CW_85 ,

 

According to your statement, I know that you are creating a calculated column. As far as I know, there should be only one data type in Power BI Column.

Facturatieoverzicht[Bedrag]/SUM(Facturatieoverzicht[Bedrag])*100 will return number type value, however "" will return text type value. 

And I suggest you to try CONTAINSSTRING() function to check whether the value contains "RFC".

Calculated column:

Column =
IF (
    CONTAINSSTRING ( Facturatieoverzicht[Omschrijving], "RFC" ),
    Facturatieoverzicht[Bedrag] / SUM ( Facturatieoverzicht[Bedrag] ) * 100,
    BLANK ()
)

Result is as below.

vrzhoumsft_0-1686296479096.png

 

Best Regards,
Rico Zhou

 

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

 

 

lbendlin
Super User
Super User

Syndicated - Outbound

1. Why ISTEXT  ?

2. Are you sure you want this as a column?  Sounds more like a use case for a measure.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)