Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.
please suggest a solution.
Hi @proavinash ,
The error occurs because UNION() only accepts two tables at a time, but you're passing in three ADDCOLUMNS() results directly. DAX cannot interpret more than two tables unless you nest the UNION() calls. To fix it, you need to combine the second and third ADDCOLUMNS() calls using UNION() first, then combine that result with the first one. Here's the corrected version of your DAX:
MTD/QTD/YTD =
var TodayDate = TODAY()
var startyear = CALCULATE(STARTOFYEAR(SaleDump[Date].[Date]), YEAR(SaleDump[Date]) = YEAR(TodayDate))
var startquarter = CALCULATE(STARTOFQUARTER(SaleDump[Date].[Date]), YEAR(SaleDump[Date]) = YEAR(TodayDate), QUARTER(SaleDump[Date]) = QUARTER(TodayDate))
var startmonth = CALCULATE(STARTOFMONTH(SaleDump[Date].[Date]), YEAR(SaleDump[Date]) = YEAR(TodayDate), MONTH(SaleDump[Date]) = MONTH(TodayDate))
var result =
UNION(
ADDCOLUMNS(CALENDAR(startyear, TodayDate), "Selection", "YTD"),
UNION(
ADDCOLUMNS(CALENDAR(startquarter, TodayDate), "Selection", "QTD"),
ADDCOLUMNS(CALENDAR(startmonth, TodayDate), "Selection", "MTD")
)
)
RETURN
result
This corrects the structure so each UNION() has exactly two inputs and avoids the scalar value conversion error.
Best regards,
SAME ERROR AGAIN.
Hi @proavinash,
Thank you for reaching out to the Microsoft Fabric Forum Community.
The UNION function returns a table as a result, so rather than creating a measure, try creating a calculated table.
Please refer the below Document:
UNION function (DAX) - DAX | Microsoft Learn
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
19 | |
13 | |
11 | |
10 | |
9 |