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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to convert my script 30000 till 39999 = COGS ?

Hi All

 

Below code no error , i like to modify :-

GL CODE  from 30000 till 39999 = COGS

 

Dax_Recode =
SWITCH(TRUE(),MAX('Table'[GL CODE])<=30000,"REVENUE",MAX('Table'[GL CODE])<=39999,"COGS",BLANK())
 
 

Paulyeo11_0-1602826506400.png

 

1 ACCEPTED SOLUTION

Hi,

This calculated column formula works fine

Column = if(AND('Table'[GL CODE]>=30000,'Table'[GL CODE]<=39999),"COGS",BLANK())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Can this work?

alex00321_0-1602828722742.png

 

Anonymous
Not applicable

Hi Sir

Thank you for sharing .

The image very blur , I Cannot see your code . Basically i need some thing like below :-

Can you share how to write in PBI ?


If([GL Code]>=30000 and [GL Code]<=39999) as [COGS],

Anonymous
Not applicable

It's just removing max:

Dax_Recode =
SWITCH(TRUE(),
Sheet1[GL CODE]<=30000,"REVENUE",
Sheet1[GL CODE]<=39999,"COGS",
BLANK())
Anonymous
Not applicable

Hi Sir

I still get error :-

The syntax for 'Table' is incorrect. (DAX(SWITCH(TRUE(),Table[GL CODE]>=30000,"COGS",Table[GL CODE]<=39999,"COGS",BLANK()))).

Paulyeo11_0-1602887698718.png

https://www.dropbox.com/s/ibrj9aa1hmiqov4/GL_%20TDS%20v0006.pbix?dl=0

Above my PBI file

Paul Yeo

Hi,

This calculated column formula works fine

Column = if(AND('Table'[GL CODE]>=30000,'Table'[GL CODE]<=39999),"COGS",BLANK())

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ash

thank you very much it work fine now.

Paul

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Anonymous , Create a new column, not measure

 

Dax_Recode =
SWITCH(TRUE(),('Table'[GL CODE])<=30000,"REVENUE",('Table'[GL CODE])<=39999,"COGS",BLANK())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors