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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sameergupta60
Helper IV
Helper IV

Help

=IF(M4>0, "P",IF((L4-M4)>0, "AP", [@[Fin Year]])) in excel is working but BI it is not working the formula

 

IMC 1 = IF('bar-1'[PPCJUl]>0,"P",if('bar-1'[PPCYTD]-'bar-1'[PPCJUl]>0,"AP", 'bar-1'[Fin year]))
 
getting an error :-Expressions that yield variant data-type cannot be used to define calculated columns.
please guide
 
1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @sameergupta60 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

bar-1:

e1.png

 

If you want to create a calculated column with dax, you may try the following codes.

Result = 
IF(
    'bar-1'[PPCJU1]>0,
    "P",
    IF(
        'bar-1'[PPCYTD]-'bar-1'[PPCJU1]>0,
        "AP",
        CONCATENATE('bar-1'[Fin year],"")
    )
)

 

If you want to create a custom column in Power Query, you may create a custom column with the following codes.

=if [PPCJU1]>0 then "P" else if ([PPCYTD]-[PPCJU1])>0 then "AP" else Text.From([Fin year])

 

e2.png

 

Result:

e3.png

 

Best Regards

Allan

 

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

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @sameergupta60 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

bar-1:

e1.png

 

If you want to create a calculated column with dax, you may try the following codes.

Result = 
IF(
    'bar-1'[PPCJU1]>0,
    "P",
    IF(
        'bar-1'[PPCYTD]-'bar-1'[PPCJU1]>0,
        "AP",
        CONCATENATE('bar-1'[Fin year],"")
    )
)

 

If you want to create a custom column in Power Query, you may create a custom column with the following codes.

=if [PPCJU1]>0 then "P" else if ([PPCYTD]-[PPCJU1])>0 then "AP" else Text.From([Fin year])

 

e2.png

 

Result:

e3.png

 

Best Regards

Allan

 

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

 

thank you so much for the help.

 

i have one more query can you guide us.

 

Colour Project1 =
VAR Dept =
SELECTEDVALUE( 'bar-1'[Slab Data] )
RETURN
Switch(True(),
Dept = "P", "#FFFFFF",
Dept = "-" , "#89de21",
Dept >"0-" , "#89de21",
Dept = "`", "#FFE12D",
Dept = ".","#d9dedd",
Dept = ",","#f56342"
)

 

in that, I have a colour cell but unable to colour the number 22,23 in a different colour can help us.

 

sameergupta60_0-1594101206111.png

 

Greg_Deckler
Super User
Super User

So you will likely need something like:

IF(M4>0, "P",IF((L4-M4)>0, "AP", [@[Fin Year]] & ""))

That assumes you want a DAX solution. If you want Power Query that is entirely different syntax

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

yes, I want a power query.

Please help on above daxPlease help on above dax

 

Can you please guide on above Dax issue

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors