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
acg
Resolver I
Resolver I

Bucketing values - what is missing?

I have written the following Dax, but do not understand what's missing:

 

Bucket Gross Value =

SWITCH(

TRUE(),

‘Fact’[Gross Value]  <=10000,"under 10'000",

‘Fact’[Gross Value] > 10000 &&’Fact’[Gross Value] <=100000,"< $100'000",

‘Fact’[Gross Value] > 100000 &&’Fact’[Gross Value] <=500000,"< $500'000",

‘Fact’[Gross Value] >500000 &&’Fact’[Gross Value] <=1000000,"< $1’000'000",

‘Fact’[Gross Value] >1000000 &&’Fact’[Gross Value] <=500000000,"< $500’000’000",   

‘Fact’[Gross Value] >500000000 &&’Fact’[Gross Value] <=1000000000,"< $1’000’000’000",

‘Fact’[Gross Value] >1000000000 &&’Fact’[Gross Value] <=50000000000,"< $50’000’000’000","> $50’000’000’000”

)

 
I know there are differnt ways to do it, but I have to do it with a Switch at the moment. It seems as if the else statement is faulty, but I don't see whats wrong. 
1 ACCEPTED SOLUTION

@tamerj1 Thank you very mich for your answer. The "$100'000" act like a text in this context. Therefore, as such the apostrphe can remain. 

It turned out the problem was that it was not in direct query. 

Once in direct query ot worked fine. 

Thank you. 

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

@acg 
Whats wrong? Do yu recieve error or you get wrong results?

Hi tamerj1, it always tries to add another bracket at the end ) and both brackets are in that browish, reddish colour - indicating that it still expects something else. 

@acg 

I discovered many sybtax errors inside the code. It seems it was written using a non standard editor. This one should work with no errors

 

Bucket Gross Value =
SWITCH (
    TRUE (),
    Fact[Gross Value] <= 10000, "under 10000",
    Fact[Gross Value] > 10000
        && Fact[Gross Value] <= 100000, "< $100000",
    Fact[Gross Value] > 100000
        && Fact[Gross Value] <= 500000, "< $500000",
    Fact[Gross Value] > 500000
        && Fact[Gross Value] <= 1000000, "< $1000000",
    Fact[Gross Value] > 1000000
        && Fact[Gross Value] <= 500000000, "< $500000000",
    Fact[Gross Value] > 500000000
        && Fact[Gross Value] <= 1000000000, "< $1000000000",
    Fact[Gross Value] > 1000000000
        && Fact[Gross Value] <= 50000000000, "< $50000000000",
    "> $50000000000"
)

 

@acg 

This is the error

BAB29EC3-A89F-464D-A9D1-CF1AAC3D190B.jpeg

@tamerj1 Thank you very mich for your answer. The "$100'000" act like a text in this context. Therefore, as such the apostrphe can remain. 

It turned out the problem was that it was not in direct query. 

Once in direct query ot worked fine. 

Thank you. 

This is a calculated column right?

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.