The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Greetings!
I have a requirement for price tracking. I have tables with history of prices like this:
Also i have table with dates(calendar). So, i tried to calculate last price on selected date:
[[S]] changing 200-300] =
VAR Last_date =
CALCULATE(
MAX('[S] products wholesale_prices_history'[changing_date]),
FILTER(
ALL('[TIMELINE] Date params'),
'[TIMELINE] Date params'[Date]<=MAX('[TIMELINE] Date params'[Date])))
RETURN
SELECTCOLUMNS(
FILTER(
CALCULATETABLE('[S] products wholesale_prices_history', ALL('[TIMELINE] Date params')),
'[S] products wholesale_prices_history'[changing_date]=Last_date
),
"Price",
MAX('[S] products wholesale_prices_history'[price])
)
Great, last price in selected date. But now i select 15.06.2023 or earlier, it gives me an error because more than 1 value got.
case 2:
VAR Last_date =
CALCULATE(
MAX('[M] ozon prices_history'[changing_date]),
FILTER(
ALL('[TIMELINE] Date params'),
'[TIMELINE] Date params'[Date]<=MAX('[TIMELINE] Date params'[Date]))
)
RETURN
IF(
CALCULATE(HASONEVALUE('[M] ozon prices_history'[article]), ALL('[TIMELINE] Date params')),
SELECTCOLUMNS(
FILTER(
CALCULATETABLE('[M] ozon prices_history', ALL('[TIMELINE] Date params')),
'[M] ozon prices_history'[changing_date]=Last_date
),
"Price",
[price]
),
"Choose product")
Hi @Sergey_Bakaev it seems from your formulas that you do not need column changing_time? If yes, remove column from your table (do not import it via Power Query or something like that) and see your results. Hope this help
Proud to be a Super User!
Hello @some_bih , thank you for your advice, but I think I will need this in order to filter the last time of the date that is selected. Correct me if I'm wrong.
All the best
Hi @Sergey_Bakaev in your picture wanted solution include article and date so time (hours and minutes) is not relevant. Hours and minutes are the lowest level of data so does not make sense to get some solution for that level of data as it can be easly filtered by date or article. So if you want to get the last time for some date then there is featues alreday - simple filter. This is the reason I "suggest" you to remove time column, if you want some solution using DAX. Hope this help
Proud to be a Super User!
I understood you. OK, I will stop using the column over time in the future.