cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mjustintaylor Frequent Visitor
Frequent Visitor

Data Ranges

Hi Community.

 

In Excel, I can create a formula to give a result on ranges between certain values e.g.

 

=IF(AND(A2>=0, A2<= 100), "Answer A",IF(AND(A2>=101, A2<=500),"Answer B", IF(AND(A2>=501, A2<=1000),"Answer 3", "Void")))

 

Is there a Dax equivalent, so I can get this to work directly in Power BI when importing and combining several spreadsheets (the If, And doesn't work)

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Data Ranges

Hi @mjustintaylor ,

 

We should get the A2 by VAR like this.

 

Measure =
VAR A2 =
    CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'Table', 'Table'[index] = 2 ) )
RETURN
    IF (
        AND ( A2 >= 0, A2 <= 100 ),
        "Answer A",
        IF (
            AND ( A2 >= 101, A2 <= 500 ),
            "Answer B",
            IF ( AND ( A2 >= 501, A2 <= 1000 ), "Answer 3", "Void" )
        )
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3

Re: Data Ranges

Hello @mjustintaylor 

 

Have you tried :

 

= IF(A2>=0 && A2 <=100,"Answer A","Answer B") or another combinations.

 

IF first option && IF second option, than ...

 

Andrej

 

 

 

mjustintaylor Frequent Visitor
Frequent Visitor

Re: Data Ranges

Thanks, Andrej

 

I will give this a go.

 

KRs

 

Justin

Community Support Team
Community Support Team

Re: Data Ranges

Hi @mjustintaylor ,

 

We should get the A2 by VAR like this.

 

Measure =
VAR A2 =
    CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'Table', 'Table'[index] = 2 ) )
RETURN
    IF (
        AND ( A2 >= 0, A2 <= 100 ),
        "Answer A",
        IF (
            AND ( A2 >= 101, A2 <= 500 ),
            "Answer B",
            IF ( AND ( A2 >= 501, A2 <= 1000 ), "Answer 3", "Void" )
        )
    )

Capture.PNG

 

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

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Users Online
Currently online: 99 members 1,574 guests
Please welcome our newest community members: