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.
Hi Guys,
So I have this master table (Rate table)
Year | Region | Branch | Target rate |
2018 | A | 098 | 80.00 % |
2018 | A | 099 | 80.00 % |
2018 | B | 100 | 80.00 % |
2019 | A | 098 | 95.00 % |
2019 | A | 099 | 95.00 % |
2019 | B | 100 | 95.00 % |
I intent to use a lookup based on the Year and Branch, to get my rate for my Fact table.
So I create this measure :
Solved! Go to Solution.
Could you share your file?
Give this measure a shot
Target Work rate = VAR myyear = MAX ( 'Date'[Year] ) VAR mybranch = VALUES ( 'Region Branch'[Branch] ) RETURN CALCULATE ( AVERAGE ( 'Target'[Target rate] ), 'Target'[Branch] IN mybranch, 'Target'[Year] = myyear )
Try replacing VALUES with MAX
Target rate related = LOOKUPVALUE ( 'Target'[Target rate], 'Target'[Branch], MAX ( 'Region Branch'[Branch] ), 'Target'[Year], MAX ( 'Date'[Year] ) )
To perry,
The diagram is something like below :
It has some duplication on Region, but for some reason we need that, and it's not the issue here 🙂
But for the branch, I can assured there is only one per year on my target table.
To Zubair,
Thanks, it's worked... Although I don;t understand why DISTINCT or VALUES not applied here ? I thought it will also make sure it elliminate duplicate ? DISTINCT with blank and VALUES with no blank, right ?
By using MAX, how it's relate with Branch or year ? that function is to return the maximum of a value right ?
Kindly enlighten me 🙂
Thanks,
VALUES function causes problem at the total row/Column. Because at the Total Row/Column, we have multiple values so it throws that error.
That's why we should use alternatives like Max/Min/SelectedValue etc
H Zubair,
Many thanks for your explanation.
Mind if I extend a bit since now I'm using MAX function. And the interesting part is, if somehow in my report, I don't display Branch, why it is shows the minimum of my Rate percentage value ? Actually I'm hoping it will be average, but before I do anything with my measure, currently it show the minimum value (while we using MAX instead)
My measure now is same like your advice (and it works for the lookup when I display Branch)
I've changed my Target table value to be like like this :
Year | Region | Branch | Target rate |
2018 | A | 098 | 80.00 % |
2018 | A | 099 | 80.00 % |
2018 | B | 100 | 65.00 % |
2018 | B | 102 | 70.00 % |
2019 | A | 098 | 95.00 % |
2019 | A | 099 | 95.00 % |
2019 | B | 100 | 80.00 % |
2019 | B | 102 | 80.00 % |
Currently it shows 65% in the year of 2018, while branch not in the report.
Thanks in advance,
Without the Branch Field, it should take the Branch 102 i.e. max of all brannches for 2018 and return the value 70%
Year | Region | Branch | Target rate |
2018 | A | 098 | 80.00 % |
2018 | A | 099 | 80.00 % |
2018 | B | 100 | 65.00 % |
2018 | B | 102 | 70.00 % |
2019 | A | 098 | 95.00 % |
2019 | A | 099 | 95.00 % |
2019 | B | 100 | 80.00 % |
2019 | B | 102 | 80.00 % |
Hi Zubair,
Yes, that was my 1st thought as well, but the actual is, it did shows the minimum value instead, which is I understand it is weird.
Anyhow, is it possible for the measure to show the average of it? So with my data ->
Year | Region | Branch | Target rate |
2018 | A | 098 | 80.00 % |
2018 | A | 099 | 80.00 % |
2018 | B | 100 | 65.00 % |
2018 | B | 102 | 70.00 % |
In average it will shows 73.75%
Thanks,
Could you share your file?
Give this measure a shot
Target Work rate = VAR myyear = MAX ( 'Date'[Year] ) VAR mybranch = VALUES ( 'Region Branch'[Branch] ) RETURN CALCULATE ( AVERAGE ( 'Target'[Target rate] ), 'Target'[Branch] IN mybranch, 'Target'[Year] = myyear )
Hi Zubair,
It worked. Many thanks for your help. 🙂
@admin_xlsior can you share relationship diagram and in which table you want rate from rate table.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
117 | |
104 | |
77 | |
73 | |
52 |
User | Count |
---|---|
145 | |
109 | |
108 | |
90 | |
64 |