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
danialsj
Frequent Visitor

Return a specific number based on multiple critera

I want to create a custom column which will contain data based on multiple conditions. The conditions are given in the rates table.


E.g. the first row of Rates: if product is type A, half year 1, year 2018, in between 0 and 500, then apply 5%.

 

I want the custom column to look like the Rate column in the Data table. How do I do this?

 

The following is my data:

 

Rates

TypeHalf YearYearMin AmountMax AmountRate
A1201805005%
A12018501100010%
B1201805003%
B1201850110006%
A2201805006%
A22018501100011%
B2201805004%
B22019501100010%
A1201905006%
A12019501100012%
B1201905004%
B12019501100010%
A2201905006%
A22019501100012%
B2201905004%
B22019501100010%

 

Data

IDTypeHalf YearYearAmountRate (Calculated Column)
1001A120181005%
1002A220185006%
1003B120192504%
1004A22019100012%
1005B2201970010%
1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @danialsj ,

 

You can create column like DAX below.

 

Rate_matched =
MAXX (
    TOPN (
        1,
        FILTER (
            Rates,
            Rates[Type] = Data[Type]
                && Rates[Half Year] = Data[Half Year]
                && Rates[Year] = Data[Year]
                && Rates[Max Amount] >= Data[Amount]
                && Rates[Min Amount] < Data[Amount]
        ),
        Rates[Year] && Rates[Half Year], DESC
    ),
    Rates[Rate]
)

Best Regards,

Amy

 

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

1 REPLY 1
v-xicai
Community Support
Community Support

Hi @danialsj ,

 

You can create column like DAX below.

 

Rate_matched =
MAXX (
    TOPN (
        1,
        FILTER (
            Rates,
            Rates[Type] = Data[Type]
                && Rates[Half Year] = Data[Half Year]
                && Rates[Year] = Data[Year]
                && Rates[Max Amount] >= Data[Amount]
                && Rates[Min Amount] < Data[Amount]
        ),
        Rates[Year] && Rates[Half Year], DESC
    ),
    Rates[Rate]
)

Best Regards,

Amy

 

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

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.