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
YavuzDuran
Helper III
Helper III

Vlookup - returning a Corresponding Value from Parameter Table

Hi All, 

 

I have a parameter table as shown below:

YavuzDuran_1-1635952482157.png

 

And all need is to match the calculated cash down % per Location for a year/month with the above cash % limits and return the corresponding $Com (Column H). 

I excel it is way easier, in Power BI I tried such a solution below

Is there any simpler way that you can suggest to me 

 

Thank you

 

 

 

 

YavuzDuran_0-1635952443434.png

 

 

Location Manager - Cash Down % Commission =
if(SalesCommission[Cash Down % - Calculated]<calculate(sum('Parameters-LocationManager'[Cash %]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=1),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),0,
if(SalesCommission[Cash Down % - Calculated]<calculate(sum('Parameters-LocationManager'[Cash %]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=2),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),calculate(sum('Parameters-LocationManager'[$ Com]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=1),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),
if(SalesCommission[Cash Down % - Calculated]<calculate(sum('Parameters-LocationManager'[Cash %]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=3),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),calculate(sum('Parameters-LocationManager'[$ Com]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=2),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),
if(SalesCommission[Cash Down % - Calculated]<calculate(sum('Parameters-LocationManager'[Cash %]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=4),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),calculate(sum('Parameters-LocationManager'[$ Com]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=3),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),
if(SalesCommission[Cash Down % - Calculated]<calculate(sum('Parameters-LocationManager'[Cash %]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=5),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),calculate(sum('Parameters-LocationManager'[$ Com]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=4),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])),
calculate(sum('Parameters-LocationManager'[$ Com]),filter('Parameters-LocationManager','Parameters-LocationManager'[Cash% Index]=5),filter('Parameters-LocationManager','Parameters-LocationManager'[Year-Month-Branch]=SalesCommission[Year-Month-Branch])))))))
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @YavuzDuran,

I modify your formula and tried to simplify these expressions, you can try to use the below formula if it helps:

Location Manager - Cash Down % Commission =
VAR filtered =
    FILTER (
        'Parameters-LocationManager',
        'Parameters-LocationManager'[Year-Month-Branch] = SalesCommission[Year-Month-Branch]
    )
VAR currIndex = 'Parameters-LocationManager'[Cash% Index]
VAR currCashDown = SalesCommission[Cash Down % - Calculated]
VAR _cashIndex1 =
    CALCULATE (
        SUM ( 'Parameters-LocationManager'[Cash %] ),
        FILTER ( filtered, [Cash% Index] = 1 )
    )
RETURN
    IF (
        currIndex = 1,
        IF ( currCashDown < _cashIndex1, 0 ),
        IF (
            currCashDown
                < CALCULATE (
                    SUM ( 'Parameters-LocationManager'[Cash %] ),
                    FILTER ( filtered, [Cash% Index] = currIndex )
                ),
            CALCULATE (
                SUM ( 'Parameters-LocationManager'[$ Com] ),
                FILTER ( filtered, [Cash% Index] = currIndex - 1 )
            ),
            CALCULATE (
                SUM ( 'Parameters-LocationManager'[$ Com] ),
                FILTER ( filtered, 'Parameters-LocationManager'[Cash% Index] = 5 )
            )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @YavuzDuran,

I modify your formula and tried to simplify these expressions, you can try to use the below formula if it helps:

Location Manager - Cash Down % Commission =
VAR filtered =
    FILTER (
        'Parameters-LocationManager',
        'Parameters-LocationManager'[Year-Month-Branch] = SalesCommission[Year-Month-Branch]
    )
VAR currIndex = 'Parameters-LocationManager'[Cash% Index]
VAR currCashDown = SalesCommission[Cash Down % - Calculated]
VAR _cashIndex1 =
    CALCULATE (
        SUM ( 'Parameters-LocationManager'[Cash %] ),
        FILTER ( filtered, [Cash% Index] = 1 )
    )
RETURN
    IF (
        currIndex = 1,
        IF ( currCashDown < _cashIndex1, 0 ),
        IF (
            currCashDown
                < CALCULATE (
                    SUM ( 'Parameters-LocationManager'[Cash %] ),
                    FILTER ( filtered, [Cash% Index] = currIndex )
                ),
            CALCULATE (
                SUM ( 'Parameters-LocationManager'[$ Com] ),
                FILTER ( filtered, [Cash% Index] = currIndex - 1 )
            ),
            CALCULATE (
                SUM ( 'Parameters-LocationManager'[$ Com] ),
                FILTER ( filtered, 'Parameters-LocationManager'[Cash% Index] = 5 )
            )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you @v-shex-msft  Will try

Greg_Deckler
Super User
Super User

@YavuzDuran Generally you would use LOOKUPVALUE or MAXX(FILTER(...),...). 

 

If you stay with your current solution, I highly recommend SWITCH(TRUE(),...) vs nested IF statements.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler will try. Thank you

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.