Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi all,
maybe some one can help me with dax code that return a value [Name] to a new column from table_A but with condition:
In other wise in table_A can be two or more rows with same [ID], but always there will be different dates in [Start_date] and [End_date] (its like periods). Sometimes can be that there will be no date in [End_date] column, for example:
ID | Start_date | End_date | Name |
2276 | 2018-01-01 | 2018-04-15 | Example |
2276 | 2020-05-01 | 2023-12-31 | Example_2 |
2276 | 2024-04-01 | Example_3 |
which means that until the End_date appears there, it should always return Example_3. In other words, table_A have the intervals when [Name] Example, Example_2 or Example_3 should be. In all other cases should leave blank.
Solved! Go to Solution.
ChatGPT do amazing things... i have copy-pasted same question in to it and it writed me a solution, that works exactly how i needed...
Name =
VAR CurrentID = table_B[ID]
VAR CurrentSalesDate = table_B[Sales date]
RETURN
IF(
ISBLANK(CurrentID) || ISBLANK(CurrentSalesDate),
BLANK(), -- Return blank if either ID or Sales date is blank
// Check if the Sales date falls within any period in table_A for the same ID
VAR MatchingName =
CALCULATE(
MAX(table_A[Name]),
table_A[ID] = CurrentID,
table_A[Start date] <= CurrentSalesDate,
OR(
ISBLANK(table_A[End date]), -- Allow for no End date (open-ended period)
table_A[End date] >= CurrentSalesDate
)
)
RETURN
COALESCE(MatchingName, "") // Return matching Name or blank if no match found
)
ChatGPT do amazing things... i have copy-pasted same question in to it and it writed me a solution, that works exactly how i needed...
Name =
VAR CurrentID = table_B[ID]
VAR CurrentSalesDate = table_B[Sales date]
RETURN
IF(
ISBLANK(CurrentID) || ISBLANK(CurrentSalesDate),
BLANK(), -- Return blank if either ID or Sales date is blank
// Check if the Sales date falls within any period in table_A for the same ID
VAR MatchingName =
CALCULATE(
MAX(table_A[Name]),
table_A[ID] = CurrentID,
table_A[Start date] <= CurrentSalesDate,
OR(
ISBLANK(table_A[End date]), -- Allow for no End date (open-ended period)
table_A[End date] >= CurrentSalesDate
)
)
RETURN
COALESCE(MatchingName, "") // Return matching Name or blank if no match found
)
I have tried multiple solutions, but everytime i have an error: "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Ask questions in Eventhouse and KQL, Eventstream, and Reflex.
User | Count |
---|---|
87 | |
79 | |
62 | |
61 | |
60 |
User | Count |
---|---|
166 | |
114 | |
99 | |
73 | |
65 |