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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
admin11
Memorable Member
Memorable Member

How to make my expression Return Blank and _ASSET ?

Hi All

 

Below expression working fine :-

 

1_REV =

SWITCH(TRUE(),

'GL'[Reporting Code_]>=00001 &&'GL'[Reporting Code_]<=00019,"REV",

BLANK())

 

Above Expression Return :- Blank AND REV

 

 

 

But

 

1_ASSET =

SWITCH(TRUE(),

'GL'[Reporting Code]>=50010 &&'GL'[Reporting Code]<=50010,"_ASSET",

'GL'[Reporting Code]>=50023 &&'GL'[Reporting Code]<=50023,"_ASSET",

'GL'[Reporting Code]>=60025 &&'GL'[Reporting Code]<=60025,"_ASSET",

BLANK())

 

)

 

Why above expression only return :- Blank ? How to make Blank and _ASSET appear ?

 

Paul

 

 

 

 

1 ACCEPTED SOLUTION
aj1973
Community Champion
Community Champion

@admin11 

You have an Extra braket in your formula

aj1973_0-1612618936923.png

 

Remark: it is better to use IF when using one condition.

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

View solution in original post

6 REPLIES 6
aj1973
Community Champion
Community Champion

Hi @admin11 

The account numbers inside the SWITCH don<t make sense

aj1973_0-1612616820668.png

 

Put the right numbers and it will work

aj1973_1-1612616909654.png

 

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

@aj1973 

Thank you very much for spot my mistake.

now i want to make the expression more simple.

 

Below is working fine :-

_

STOCK =

SWITCH(TRUE(),

'GL'[Reporting Code]>=50010 &&'GL'[Reporting Code]<=50010,"STOCK",

BLANK())

 

 

How to convert above expression to Below  and make it working :-

_STOCK_ =

SWITCH(TRUE(),

'GL'[Reporting Code]=50010,"STOCK_",

BLANK())

)

 

https://www.dropbox.com/s/ps32ecvuf8225lo/PBT%20GL%20VER0055%20GL%20ANALYSIS%20PROBLEM%20STATEMENT%2...

aj1973
Community Champion
Community Champion

@admin11 

You have an Extra braket in your formula

aj1973_0-1612618936923.png

 

Remark: it is better to use IF when using one condition.

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

@aj1973 

@PhilipTreacy 

Now working fine.

Thank you both

Paul

PhilipTreacy
Super User
Super User

@admin11 

Hi Paul,

What exactly are you trying to do?

When you say you want the measure to return BLANK() and _ASSET I presume you mean under different conditions?

The logic in your measure isn't right.  For each line what you are actually saying is check if GL[Reporting Code] is equal to a specific value.

When you write

 

'GL'[Reporting Code]>=50010 &&'GL'[Reporting Code]<=50010

 

that's the same as 

 

'GL'[Reporting Code] = 50010

 

and that's the same for each line.  Your upper and lower limits for the tests are the same value so you may as well just test for equality.

 

1_ASSET =

SWITCH(TRUE(),

'GL'[Reporting Code] = 50010 , "_ASSET",

'GL'[Reporting Code] = 50023 , "_ASSET",

'GL'[Reporting Code] = 60025 , "_ASSET",

BLANK())

)

 

 

So looking at that, the string _ASSET will only be returned when 'GL'[Reporting Code] is equal to 50010, 50023 or 60025.  Otherwise you'll get BLANK().

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacy 

 

Thank you for sharing :-

 

I just try to create a expression , is working fine :-

_

STOCK =

SWITCH(TRUE(),

'GL'[Reporting Code]>=50010 &&'GL'[Reporting Code]<=50010,"STOCK",

BLANK())

 

 

But Below not working :-

 

_STOCK_ =

SWITCH(TRUE(),

'GL'[Reporting Code]=50010,"STOCK_",

BLANK())

)

 

Hope you can advise me

 

https://www.dropbox.com/s/ps32ecvuf8225lo/PBT%20GL%20VER0055%20GL%20ANALYSIS%20PROBLEM%20STATEMENT%2...

 

My PBI file

 

Paul

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.