Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Dear members hi.
I really need your help!
I have a calculated column where I am retrieving the max ID from another table based on specific parameters.
My code is as follows:
Calculate(Max('Table1'[ID]), Filter(
Filter (
Filter(
Table1[countryid]=table2[countryid]),
Table1[cityid]=table2[cityid]),
Table1[start date]<=table2[date] &&
Table1[end date]>table2[date] ),
Table1 [flag]=false)
)
I need a way either to optimize this calculated column or reproduce this code as measure .
Any ideas on how to do it??
Thank you very much in advance 🙂
Solved! Go to Solution.
Sorry to hear that. Here's a different variation to reduce the number of rows scaned.
MaxIDMeasure =
VAR MaxCountryID = MAX('table2'[countryid])
VAR MaxCityID = MAX('table2'[cityid])
VAR MaxDate = MAX('table2'[date])
RETURN
CALCULATE(
MAX('Table1'[ID]),
'Table1'[countryid] = MaxCountryID,
'Table1'[cityid] = MaxCityID,
'Table1'[start date] <= MaxDate,
'Table1'[end date] > MaxDate,
'Table1'[flag] = FALSE()
)
Proud to be a Super User!
Hi @Dimitris_Kats ,
You can try this as a measure:
MaxIDMeasure =
CALCULATE(
MAX('Table1'[ID]),
FILTER(
'Table1',
'Table1'[countryid] = MAX('table2'[countryid]) &&
'Table1'[cityid] = MAX('table2'[cityid]) &&
'Table1'[start date] <= MAX('table2'[date]) &&
'Table1'[end date] > MAX('table2'[date]) &&
'Table1'[flag] = FALSE()
)
)
Proud to be a Super User!
Hello @amustafa
Thank you very much for replying to me.
I have already tried this measure. Unfortunately it's loading forever and fails 😞
Sorry to hear that. Here's a different variation to reduce the number of rows scaned.
MaxIDMeasure =
VAR MaxCountryID = MAX('table2'[countryid])
VAR MaxCityID = MAX('table2'[cityid])
VAR MaxDate = MAX('table2'[date])
RETURN
CALCULATE(
MAX('Table1'[ID]),
'Table1'[countryid] = MaxCountryID,
'Table1'[cityid] = MaxCityID,
'Table1'[start date] <= MaxDate,
'Table1'[end date] > MaxDate,
'Table1'[flag] = FALSE()
)
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
45 | |
26 | |
22 | |
13 | |
8 |
User | Count |
---|---|
73 | |
51 | |
45 | |
16 | |
12 |