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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ma_ltei
Regular Visitor

Measure related to a certain date

Hello dear Power Bi community users,

 

i'm trying to do somehting which i'm sure is easy to do but that i'm getting mad about 😄

 

I have a table where each line contains some informations for a certain date :

 

DateProductPriceIndexFactor
2022-01-01A2,5 €12,5
2022-01-01B2,9 €12,9
2022-02-01A3,4 €1,13,09
2022-02-01B3,2 €1,12,91
2022-03-01A4,1 €1,23,41
2022-03-01B3,8 €1,23,16

 

My goal here is to display two lines :

 

First one : Price evolution per date

Seconde one : Index evolution rebased on 2022-01-01 ( Index values * 2022-01-01 factor )

 

So for product A : 1 / 1,1 / 1,2 * 2,5 = 2,5 / 2,75 / 3

So for product B : 1 / 1,1 / 1,2 * 2,9 = 2,9 / 3,19 / 3,48

 

To do this I created a measure that multiplies the Index value per the factor value that is calculated for the MIN of date so that it adapts automatically to the product selected, but it doesnt work :

 

it does show this : Product A : 1 * 2,5 / 1,1 * 3,09 / 1,2 * 3,41 = 2,5 / 3,4 / 4,1

instead of this : Product A :      1 / 1,1 / 1,2 * 2,5                     = 2,5 / 2,75 / 3

 

Here is the measure used : factor_to_use = CALCULATE(MIN(Sheet1[Factor]), FILTER(Sheet1,Sheet1[Date]=MIN(Sheet1[Date])),ALLEXCEPT(Sheet1,Sheet1[Product]))

 

Can you help me correct the measure OR find the correct formula to display in the factor column only the factor value calculated for the min date available per product ?

 

Thanks a lot 🙂

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

Hi @ma_ltei ,

 

Approve with @amitchandak , the MIN(Sheet1[Factor]) is not simply calculate the min of the value, it is used with FIRSTNONBLANK(), it returns the first value in the column, column, filtered by the current context, where the expression is not blank. So you will get the value of the factor for the min date.

Besides, here is another solution:

Measure 2 =

var _a = CALCULATE(MIN([Date]),ALLEXCEPT(Sheet1,Sheet1[Product]))

return CALCULATE(MIN('Sheet1'[Factor]),FILTER(ALL('Sheet1'),[Date]=_a&&[Product]=MAX([Product])))

Output:

vjianbolimsft_0-1659518684838.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @ma_ltei ,

 

Approve with @amitchandak , the MIN(Sheet1[Factor]) is not simply calculate the min of the value, it is used with FIRSTNONBLANK(), it returns the first value in the column, column, filtered by the current context, where the expression is not blank. So you will get the value of the factor for the min date.

Besides, here is another solution:

Measure 2 =

var _a = CALCULATE(MIN([Date]),ALLEXCEPT(Sheet1,Sheet1[Product]))

return CALCULATE(MIN('Sheet1'[Factor]),FILTER(ALL('Sheet1'),[Date]=_a&&[Product]=MAX([Product])))

Output:

vjianbolimsft_0-1659518684838.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@ma_ltei , try like

Calculate(firstnonblankvalue(Sheet1[Date], MIN(Sheet1[Factor])), ALLEXCEPT(Sheet1,Sheet1[Product]))

 

 

Use in place of max here

https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hello amitchandak,

 

Thanks a lot but i don't understand the MIN(Sheet1[Factor]) as I dont need the min of the value but the value of the factor for the min date where this information is available ?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.