March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
Hello everyone,
I have the following raw data from the pricing sharepoint:
ID; Date on which the price was modified (updated), Start/End of the price period, the respective price), and a key (ID+Currency).
OriginalID | Modified | Rank | Index | StartDateP1 | EndDateP1 | Price End P1 | StartDateP2 | EndDateP2 | Price End P2 | Key |
1111 | 4.3.2021 | 4 | 1 | 1.1.2021 | 31.12.2021 | 9,19 | 1111EUR | |||
1111 | 29.21.2021 | 2 | 2 | 1.1.2021 | 31.12.2021 | 9,19 | 1.1.2022 | 31.12.2022 | 9,19 | 1111EUR |
1111 | 8.4.2022 | 3 | 3 | 1.1.2021 | 31.12.2021 | 9,19 | 1.1.2022 | 31.12.2022 | 9,17 | 1111EUR |
1111 | 12.4.2022 | 1 | 4 | 31.12.2020 | 30.12.2021 | 9,19 | 31.12.2022 | 9,17 | 1111EUR | |
2222 | 16.3.2022 | 4 | 5 | 31.12.2021 | 30.12.2022 | 50,01 | 31.12.2022 | 31.12.2023 | 52,71 | 2222EUR |
2222 | 23.3.2022 | 3 | 6 | 31.12.2021 | 30.12.2022 | 51,71 | 31.12.2022 | 31.12.2023 | 52,71 | 2222EUR |
2222 | 29.3.2022 | 2 | 7 | 31.12.2021 | 30.12.2022 | 51,71 | 31.12.2022 | 31.12.2023 | 52,71 | 2222EUR |
2222 | 18.4.2022 | 1 | 8 | 31.12.2021 | 30.12.2022 | 51,71 | 31.12.2022 | 31.12.2023 | 52,71 | 2222EUR |
I have created a formula that finds the 22' price from each price update:
The problem is that in some cases the first row in the 22' Price is Blank, because there was no 22' price in the beginning. It means that I need the first non blank price.
Do you have any ideas?
Thanks,
Leo
Solved! Go to Solution.
You need to apply FIRSTNONBLANK to the date. Then use that date as the filter to get the price at that date.
Also look into FIRSTNONBLANKVALUE - that might save you a step.
Or use the pedestrian way
22 Price =
var m = min('Table'[Modified])
return CALCULATE(sum('Table'[Price End P2]),'Table'[Modified]=m)
Hi @Anonymous
Please refer to sample file with the solution https://www.dropbox.com/t/0WkCrxsXlYxewGbb
22' Original Price =
VAR CurrentIDTable = CALCULATETABLE ( Data, ALLEXCEPT ( Data, Data[OriginalID] ) )
VAR NonBlankTable = FILTER ( CurrentIDTable, Data[22' Price] <> BLANK ( ) )
VAR FirstRecord = TOPN ( 1, NonBlankTable, Data[Index], ASC )
RETURN
MAXX ( FirstRecord, Data[22' Price] )
Thank you so much, @tamerj1
It works perfectly and it is exactly what I needed.
Hi @Anonymous
Please refer to sample file with the solution https://www.dropbox.com/t/0WkCrxsXlYxewGbb
22' Original Price =
VAR CurrentIDTable = CALCULATETABLE ( Data, ALLEXCEPT ( Data, Data[OriginalID] ) )
VAR NonBlankTable = FILTER ( CurrentIDTable, Data[22' Price] <> BLANK ( ) )
VAR FirstRecord = TOPN ( 1, NonBlankTable, Data[Index], ASC )
RETURN
MAXX ( FirstRecord, Data[22' Price] )
Thank you so much, @tamerj1
It works perfectly and it is exactly what I needed.
I would recommend you unpivot your data before proceeding. Or use FIRSTNONBLANK if you are in a hurry.
You need to apply FIRSTNONBLANK to the date. Then use that date as the filter to get the price at that date.
Also look into FIRSTNONBLANKVALUE - that might save you a step.
Or use the pedestrian way
22 Price =
var m = min('Table'[Modified])
return CALCULATE(sum('Table'[Price End P2]),'Table'[Modified]=m)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
157 | |
97 | |
79 | |
69 |