Skip to content

Commit bc7ad4c

Browse files
committed
fixed 2 comments
1 parent f775d81 commit bc7ad4c

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/sempy_labs/tom/_model.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,32 +3664,32 @@ def add_time_intelligence(
36643664
)
36653665

36663666
# Validate measure and extract table name
3667-
try:
3668-
table_name = next(
3669-
m.Parent.Name for m in self.all_measures() if m.Name == measure_name
3670-
)
3671-
except:
3672-
raise ValueError(
3673-
f"{icons.red_dot} The '{measure_name}' is not a valid measure in the '{self._dataset}' semantic model within the '{self._workspace}' workspace."
3674-
)
3667+
matching_measures = [
3668+
m.Parent.Name for m in self.all_measures() if m.Name == measure_name
3669+
]
3670+
3671+
if not matching_measures:
3672+
raise ValueError("{icons.red_dot} The '{measure_name}' is not a valid measure in the '{self._dataset}' semantic model within the '{self._workspace}' workspace.")
36753673

3674+
table_name = matching_measures[0]
36763675
# Validate date table
36773676
if not self.is_date_table(date_table):
36783677
raise ValueError(
36793678
f"{icons.red_dot} The '{date_table}' table is not a valid date table in the '{self._dataset}' semantic model within the '{self._workspace}' workspace."
36803679
)
36813680

36823681
# Extract date key from date table
3683-
try:
3684-
date_key = next(
3685-
c.Name
3686-
for c in self.all_columns()
3687-
if c.Parent.Name == date_table and c.IsKey
3688-
)
3689-
except:
3682+
matching_columns = [
3683+
c.Name
3684+
for c in self.all_columns()
3685+
if c.Parent.Name == date_table and c.IsKey
3686+
]
3687+
3688+
if not matching_columns:
36903689
raise ValueError(
3691-
f"{icons.red_dot} The '{date_table}' table does not have a date key column in the '{self._dataset}' semantic model within the '{self._workspace}' workspace."
3692-
)
3690+
f"{icons.red_dot} The '{date_table}' table does not have a date key column in the '{self._dataset}' semantic model within the '{self._workspace}' workspace.")
3691+
3692+
date_key = matching_columns[0]
36933693

36943694
# Create the new time intelligence measures
36953695
for t in time_intel:

0 commit comments

Comments
 (0)