Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Question: In the calculated column below, we are determining the Last Year Unit price for suppliers. However, new suppliers lack data, resulting in blank rows. I need to amend the logic in the column to populate these blank values with those from existing suppliers for the same material number. Our data contains pairs of suppliers, and we want to use the value from the supplier that has the data.
I have managed to create a ‘test’ secondary calculated column that provides the results (shown below). I need to figure out a way to do this all in one column.
Any help or suggestions would be greatly appreciated!
Main Calculated Column:
LYUnitPriceUSD_DEC =
VAR __LastYearKey = Table1[Column1] & "_" & Table1[Year]-1 & "_Q" & Table1[Quarter]
VAR __ExcelValue = LOOKUPVALUE(
Table2[PriceLastYear],
Table2[Key],
__LastYearKey)
VAR __SAPValue =
LOOKUPVALUE(
Table3[AveragePrice],
Table3[Key],
Table1[Column1] & "_" & Table1[Year]-1)
VAR __CurrentRateYearCode =
LEFT( RELATED(Table4[CurrencyYear]) , 3 )
& "_" &
IF(
Table1[Year] > YEAR( TODAY() ),
YEAR( TODAY() ),
Table1[Year])
VAR __RateMultiplication =
LOOKUPVALUE(Table5[RateMultiplier],
Table5[CurrencyYearKey],
__CurrentRateYearCode)
VAR __SAPValueCurrentRate = __SAPValue * __RateMultiplication
VAR __Result = COALESCE(__ExcelValue,__SAPValueCurrentRate)
RETURN __Result
Test Column for Reference:
Find Duplicate Value test =
VAR __Exclude = CALCULATETABLE( VALUES(Table6[SupplierName]), Table6[Exclude] = "Exclude" )
VAR __AlternateLYValue =
IF( NOT( ISBLANK(Table1[LYUnitPriceBudatUSD_DEC]) && NOT( Table1[SupplierName] IN __Exclude ) ),
Table1[LYUnitPriceBudatUSD_DEC],
CALCULATE(
MAX( Table1[LYUnitPriceBudatUSD_DEC] ),
FILTER( Table1,
Table1[Year] = EARLIER( Table1[Year] )
&& Table1[ArticleNo] = EARLIER( Table1[ArticleNo] )
&& NOT( ISBLANK( Table1[LYUnitPriceBudatUSD_DEC]))
&& NOT( Table1[SupplierName] IN __Exclude ) ) ) )
RETURN __AlternateLYValue
Disclosure: This question was assisted by AI.
Solved! Go to Solution.
Read about COALESCE
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |