sqlexcelpowerbipowerquerytableau-desktop

How to identify slabs based on a config table in SQL or excel


I have 2 tables, a Transaction table and Config table. enter image description here

enter image description here

Based on the percentage achieved, I need to identify slab and rating from the config table. Config table values can undergo changes including the slabs. So I need to dynamically map.

Can anyone help or provide guidance please.


Solution

  • you can try this in powerbi

    Slab =
    IF (
        'Transaction'[percentage] * 100 >= 120,
        "Slab 5",
        MAXX (
            FILTER (
                Config,
                'Transaction'[percentage] * 100 >= Config[From]
                    && 'Transaction'[percentage] * 100 < [To]
            ),
            Config[Slab]
        )
    )
    
    Rating =
    MAXX ( FILTER ( Config, 'Transaction'[Slab] = Config[Slab] ), 'Config'[Rating] )
    

    enter image description here