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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
lk01
Frequent Visitor

How to lookup/calulcate for every day (date)

Hi,

let's hope someone can help me 🙂
I got the following table (simplified)

Cust-IdProd-IDValid FromValue
001001201.01.202215,5
001001201.06.202214,9
001001301.07.202222,1
001001430.06.20187,9
002001501.04.202014,4
002001601.05.202020
002001601.07.202244,8
003001715.04.201932,15
003001801.07.20218,6
003001901.02.202015,7
003001901.04.202216,2
 ...  

 

Values for each product-id which are valid_from a certain date to a newer valid_from date    (sorry for the english)
How can I get to a table or measure (dax?) and arrive here:?

 

dateProd-IDValue
01.01.2022001215,5
01.01.2022001322,1
01.01.202200147,9
01.01.2022001514,4
01.01.2022001620
01.01.2022001732,15
01.01.202200188,6
01.01.2022001915,7
02.01.2022001215,5
02.01.2022001322,1
02.01.202200147,9
02.01.2022001514,4
02.01.2022001620
02.01.2022001732,15
02.01.202200188,6
02.01.2022001915,7
  
01.04.2022001215,5
01.04.2022001322,1
01.04.202200147,9
01.04.2022001514,4
01.04.2022001620
01.04.2022001732,15
01.04.202200188,6
01.04.2022001916,2

The highlighted value is just for clarification what should happen

 

It doesn't have to be a separate table.
I need to calculate the value for each prod-id in a certain period
f.e..   

fromtoprod-idvalue (sum)
01.01.202231.01.20220012480,5
    

Minus saturdays and sundays if possible 😉

I'm relatively new to Power BI and can't wrap my head around this atm

Help would really be appreciated, thank you.

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @lk01 

I still have some doubts about your expected results.

veasonfmsft_1-1671074526144.png

On January 1, 2022, the value corresponding to Prod-ID=0013 should be empty rather than 22,1, right?

 

veasonfmsft_0-1671074488677.png

If so, I recommend creating two separate dimension tables: “Date” table and "Prod" table.

Calculated  table:

Date = CALENDAR(DATE(2022,1,1),DATE(2022,4,1) )
Prod = VALUES(Table1[Prod-ID]) 

Then try measure  like:

Valid date = CALCULATE(MAX(Table1[Valid From]),FILTER(Table1,Table1[Valid From]<=MAX('Date'[Date])&&Table1[Prod-ID]=MAX(Prod[Prod-ID])))
Value = CALCULATE(MAX(Table1[Value]),FILTER('Table1',Table1[Valid From]=[Valid date]&&Table1[Prod-ID]=MAX(Prod[Prod-ID])))
final result = SUMX(VALUES('Date'[Date]),[Value]) 

veasonfmsft_2-1671075041228.png

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi, @lk01 

I still have some doubts about your expected results.

veasonfmsft_1-1671074526144.png

On January 1, 2022, the value corresponding to Prod-ID=0013 should be empty rather than 22,1, right?

 

veasonfmsft_0-1671074488677.png

If so, I recommend creating two separate dimension tables: “Date” table and "Prod" table.

Calculated  table:

Date = CALENDAR(DATE(2022,1,1),DATE(2022,4,1) )
Prod = VALUES(Table1[Prod-ID]) 

Then try measure  like:

Valid date = CALCULATE(MAX(Table1[Valid From]),FILTER(Table1,Table1[Valid From]<=MAX('Date'[Date])&&Table1[Prod-ID]=MAX(Prod[Prod-ID])))
Value = CALCULATE(MAX(Table1[Value]),FILTER('Table1',Table1[Valid From]=[Valid date]&&Table1[Prod-ID]=MAX(Prod[Prod-ID])))
final result = SUMX(VALUES('Date'[Date]),[Value]) 

veasonfmsft_2-1671075041228.png

Best Regards,
Community Support Team _ Eason

Thank you for your efforts, this is looking better already! 🙂

Yes, that was a typo on my part .. it should be empty in this case, though the real data-table has valid_from dates that go way back.

Still trying to figure out how you did it, but I take what I can get 😉

One more question: trying to group the values by Cust-Id does not work correctly, even when I add cust-id to the Prod table    ( SUMMARIZE(Table1,Table1[Prod-ID],Table1[Cust-Id]) )

lk01_2-1671088233034.png

Do I need a new measure for this?

Hi, @lk01 

Yes. You may need to replace [Prod-id] with [Cust-Id] in all my original measures.

 

Best Regards,
Community Support Team _ Eason

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.