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

Join 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.

Reply
rsanyoto
Helper III
Helper III

How to calculate value based on lookup on multiple date columns

Hi everyone,

 

Currently i'm stuck with the following requirements:

 

  • Tabel Fact_ValueEntry contains transactions based on columns  [ProductionOrderFK] (updated), [ValueEntryPK], [PostingDate] and [ItemFK].
  • Table Dim_PurchasePrice contains information about prices of items based on [StartingDate] en [EndingDate] and [ItemFK].
  • A relationship of Many To Many is created between these two tables.

 

I need to calculate the correct value of column [DirectUnitCost] based on each [ProductionOrderFK] the following condition:

If a transaction in table Fact_ValueEntry has a PostingDate that comes in the range between [StartingDate] en [EndingDate], then show the value of [DirectUnitCost], otherwise null.

 

For example: the correct value of column [DirectUnitCost] for ItemFK : MXM30.0780 thats created on 30/4/2020 would be 1,57.

 

Many to Many on ItemPK : ItemPKMany to Many on ItemPK : ItemPKFact_ValueEntryFact_ValueEntryDim_PurchasePriceDim_PurchasePrice

What would be a good Measure in this case?

 

 

Kind Regards,

 

Regazzi

 

1 ACCEPTED SOLUTION

Hi @rsanyoto ,

 

Many to Many relationship is always troublesome.

You'd better create a dim table between  the 2 tables which is using 1:M relatioship to connect the 2 tables and get the DirectUnitCost values.

 

Best Regards,
Kelly

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

View solution in original post

4 REPLIES 4
rsanyoto
Helper III
Helper III

Has anyone a better suggestions? Kind regards

amitchandak
Super User
Super User

@rsanyoto , you can create a flag column in first table

 

New col =

var _cnt = countx(filter(Table2, Table1[Posting Date]>= Table2[Start Date]  && Table1[Posting Date]<= Table2[End Date] )), Table2[Item FK])

 

return

if(Isblank(_cnt), false(), true())

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

hI @amitchandak ,

 

the option you gave me doesnt meet my requirements. it's because the expected output must not be a true/false but a number.

 

 

Please see the following table as a expected result

 

ProductionOrderFKItemFKPostingDateStartingDateEndingDateDirectUnitCost
VPO-200776MXM30.078030/04/202001/04/202031/08/20201,57
      

 

The 1,57 amount is created becasue there was a transaction on 30th april and thats a date between period of 01 april and 31 of augustus.

Hi @rsanyoto ,

 

Many to Many relationship is always troublesome.

You'd better create a dim table between  the 2 tables which is using 1:M relatioship to connect the 2 tables and get the DirectUnitCost values.

 

Best Regards,
Kelly

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

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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