Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
komaragiri
Frequent Visitor

Lookup tables and calculate % value.

I have 2 tables.  

 

 

Vendor NameTotal Value
ABC10000
XYZ20000
ABCD50000
T2-VendorFrom ValueTo ValuePercentage
ABC050005%
ABC50011000010%
ABC1000110000020%
XYZ050005%
XYZ50011000010%
XYZ1000110000020%
ABCD010000015%
    

 

I need to Look Vendor name from Table 1 to Table 2.  Once I find the value, See if the Total Value from Table 1 falls in to which range to get the Percentage Value.   Store the Pecentage value on the Table 1 as column against each row.  

Need DAX formula for column creation. 

 

Final Results (Table 1, after adding colum pecentage)  

Vendor NameTotal ValuePercentageDiscount
ABC1000010%1000
XYZ2000020%4000
ABCD5000015%7500

Appreciate your help.  

 

2 ACCEPTED SOLUTIONS
some_bih
Super User
Super User

Hi @komaragiri create two columns in vendor table as

Value Percentage and Discount. Adjust your table names / columns accordingly and you should get Output

 

 

Value Percentage =
CALCULATE(
    MAX(Table2[Percentage]),
        FILTER(
        Table2,Table2[Vendor]=Vendor[Vendor Name] && Table2[From Value]<=Vendor[Total Value] && Table2[To Value]>=Vendor[Total Value]
        )
)
 
Discount = ROUND(Vendor[Total Value]*Vendor[Value Percentage],2)
 
Output
some_bih_0-1714716515530.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

AntrikshSharma
Super User
Super User

@komaragiri You can build a relationship between 2 tables assuming the Table1 won't have duplicates in future.

AntrikshSharma_0-1714717080848.png

In Table1 you can create a the column using:

 

Discount = 
VAR T1_TotalValue = Table1[Total Value]
VAR T2_SameRows = 
    CALCULATETABLE ( 
        Table2,     
        T1_TotalValue >= Table2[From Value]
            && T1_TotalValue <= Table2[To Value] 
    )
VAR Result = 
    SUMX ( T2_SameRows, Table2[Percentage] * T1_TotalValue )
RETURN 
    Result

 

AntrikshSharma_1-1714717161612.png

 

You can also create the column in Table2 using:

 

Discount = 
VAR T1_TotalValue = 
    RELATED ( Table1[Total Value] )
VAR ValueInRange = 
    T1_TotalValue >= Table2[From Value]
        && T1_TotalValue <= Table2[To Value]
VAR Result = 
    ( Table2[Percentage] * T1_TotalValue ) * ( ValueInRange * 1 )
RETURN 
    Result

 

 

AntrikshSharma_2-1714717236183.png

 

 

 

View solution in original post

3 REPLIES 3
komaragiri
Frequent Visitor

thank you for your solutions 

AntrikshSharma
Super User
Super User

@komaragiri You can build a relationship between 2 tables assuming the Table1 won't have duplicates in future.

AntrikshSharma_0-1714717080848.png

In Table1 you can create a the column using:

 

Discount = 
VAR T1_TotalValue = Table1[Total Value]
VAR T2_SameRows = 
    CALCULATETABLE ( 
        Table2,     
        T1_TotalValue >= Table2[From Value]
            && T1_TotalValue <= Table2[To Value] 
    )
VAR Result = 
    SUMX ( T2_SameRows, Table2[Percentage] * T1_TotalValue )
RETURN 
    Result

 

AntrikshSharma_1-1714717161612.png

 

You can also create the column in Table2 using:

 

Discount = 
VAR T1_TotalValue = 
    RELATED ( Table1[Total Value] )
VAR ValueInRange = 
    T1_TotalValue >= Table2[From Value]
        && T1_TotalValue <= Table2[To Value]
VAR Result = 
    ( Table2[Percentage] * T1_TotalValue ) * ( ValueInRange * 1 )
RETURN 
    Result

 

 

AntrikshSharma_2-1714717236183.png

 

 

 

some_bih
Super User
Super User

Hi @komaragiri create two columns in vendor table as

Value Percentage and Discount. Adjust your table names / columns accordingly and you should get Output

 

 

Value Percentage =
CALCULATE(
    MAX(Table2[Percentage]),
        FILTER(
        Table2,Table2[Vendor]=Vendor[Vendor Name] && Table2[From Value]<=Vendor[Total Value] && Table2[To Value]>=Vendor[Total Value]
        )
)
 
Discount = ROUND(Vendor[Total Value]*Vendor[Value Percentage],2)
 
Output
some_bih_0-1714716515530.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.