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
Anonymous
Not applicable

Match value in table A with B

Hi all, 

 

I am trying to write a measure to match the usage in table A with the pricing in table B. 

 

Table A: 

customer_nameTypeusageTier ranking pricing
AStandard20??
BStandard55??
CExecutive55??
DExecutive126??

 

Table B: 

TypeTier rankingMinMaxpricing
Standard105$0.00
Standard2615$50.00
Standard31635$48.00
Standard43670$45.88
Standard571125$43.63
Standard6126205$41.25
Executive105$100.00
Executive2615$95.00
Executive31635$90.00
Executive43670$85.00
Executive571125$80.00
Executive6126205$75.00

 

The DAX measure I need to calculate is the "Tier Ranking" and "Pricing" in table A; it would match the usage accordingly to the Min and Max in table B to decide which tier a customer is in, and how much they should be charged. 

 

So the result should be like this: 

customer_nameTypeusageTier ranking pricing
AStandard203$48.00
BStandard554$45.88
CExecutive554$85.00
DExecutive1266$75.00

 

I have been trying to use a lot of IF functions but it's not working. I greatly appreciate any advice and help! 

 

Thank you all, 

 

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

Hello @Anonymous 

If the Min values from table B are static then you can add a calculated column to get the Min target for Table A based on the usage.

MinValue = 
VAR RowUsage = TableA[usage]
RETURN
SWITCH (
    TRUE (),
    RowUsage < 6, 0,
    RowUsage < 16, 6,
    RowUsage < 36, 16,
    RowUsage < 71, 36,
    RowUsage < 126, 71,
    126)

Then it is just a couple of LOOKUPVALUE columns to get Tier and Pricing

Tier Ranking = 
LOOKUPVALUE ( TableB[Tier ranking], TableB[Type], TableA[Type], TableB[Min], TableA[MinValue] )
Pricing = 
LOOKUPVALUE ( TableB[pricing], TableB[Type], TableA[Type], TableB[Min], TableA[MinValue] )

pricinglookup.jpg

View solution in original post

Hello @Anonymous ,

We can't easily create a calculated column on table A becasue the usage is a distinct count of table A.  This measure will pull the pricing based on the usage and tier though.

Pricing = 
VAR Tier = SELECTEDVALUE ( TableA[Tier Type] )
RETURN
CALCULATE(
    MAX(TableB[pricing]),
            FILTER(
                TableB,
                TableB[Type] = tier &&
                [usage] >= TableB[Min]
                && [usage] <= TableB[Max] )
    )

pricing.jpg

View solution in original post

11 REPLIES 11
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jdbuchanan71
Super User
Super User

Hello @Anonymous 

If the Min values from table B are static then you can add a calculated column to get the Min target for Table A based on the usage.

MinValue = 
VAR RowUsage = TableA[usage]
RETURN
SWITCH (
    TRUE (),
    RowUsage < 6, 0,
    RowUsage < 16, 6,
    RowUsage < 36, 16,
    RowUsage < 71, 36,
    RowUsage < 126, 71,
    126)

Then it is just a couple of LOOKUPVALUE columns to get Tier and Pricing

Tier Ranking = 
LOOKUPVALUE ( TableB[Tier ranking], TableB[Type], TableA[Type], TableB[Min], TableA[MinValue] )
Pricing = 
LOOKUPVALUE ( TableB[pricing], TableB[Type], TableA[Type], TableB[Min], TableA[MinValue] )

pricinglookup.jpg

Anonymous
Not applicable

Hi @jdbuchanan71 , thank you very much for your solution. It works perfectly for this sample model. However, when I apply to my actual model, where the "usage in table A is a measure (distinct count of a text), the calculated column MinValue does not work. It returns 0 for all. I am not sure how to work around this issue. Thank you very much for your help. 

@Anonymous 

Try adding the usage as a calculated column in Table A simply by adding a column and putting in =[usage measure].  Does that get you what you need?  If not, please share your .pbix file so we can see how the data is actually organized.

Anonymous
Not applicable

Hi @jdbuchanan71 ,

 

I tried to create a column and has it formulated as you suggested: count unique map =[usage measure]. It would sum up the distinct count as 6 like below

Capture4.JPG

My usage measure is: usage = DISTINCTCOUNT(TableA[Maps])

If I do the Count (Distinct) of "Maps" in the Values, it would count correctly like "usage", but I cannot use it as a calculated column. 

Is there a way to create a calculated column that works just like the measure for "usage"? 

 

Thank you, I hope I explain it well. 

 

@Anonymous 

I don't know what your measure for "usage' looks like.  Can you share your .pbix file?

Anonymous
Not applicable

Hi @jdbuchanan71 , my usage measure is simple, this is it: usage = DISTINCTCOUNT(TableA[Maps]). 

 

I do not know how to share a .pbix file here in the forum. Can you walk me through? 

 

Much appreciate your quick response,

 

You can just upload the file to OneDrive or DropBox then share the link here.

Anonymous
Not applicable

Hi @jdbuchanan71 

This is my .pbix file here

I tried to create a calculated column that works the same as the measure "usage", so that I can use the DAX you suggested for MinValue, but no success so far. 

So ultimately, in TableA I need to create calculated columns to LOOKUP for "Tier Ranking" and "Pricing" from Table B. 

 

Thank you very much for your help, 

 

 

Hello @Anonymous ,

We can't easily create a calculated column on table A becasue the usage is a distinct count of table A.  This measure will pull the pricing based on the usage and tier though.

Pricing = 
VAR Tier = SELECTEDVALUE ( TableA[Tier Type] )
RETURN
CALCULATE(
    MAX(TableB[pricing]),
            FILTER(
                TableB,
                TableB[Type] = tier &&
                [usage] >= TableB[Min]
                && [usage] <= TableB[Max] )
    )

pricing.jpg

Anonymous
Not applicable

thank you very much @jdbuchanan71 ! 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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