Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi can anyone help me correct my calculated column, i want the sum of remaining of group1 and 2 on my column. Show error when i try to used below.
Solved! Go to Solution.
Hi,
I am not sure how the expected result looks like, but please try something like below, and please check whether it works.
Thank you.
TA_Total_Column_Remaining =
VAR CurrentDate =
TODAY ()
VAR CurrentGroup = { "Group01", "Group02" }
RETURN
CALCULATE (
SUM ( 'Table'[Remaining] ),
FILTER (
'Table',
'Table'[PlanDate] = CurrentDate && 'Table'[Trade] IN CurrentGroup
)
)
Hi @AllanBerces
The error in your DAX formula occurs because of how you are using the variable CurrentGroup and the IN operator. In DAX, you can’t assign a logical expression like 'Table'[Trade] IN {"Group01", "Group02"} to a variable and then later compare a column directly to that variable — it results in an invalid data type or logical context error. Also, using CALCULATE inside a calculated column can behave unexpectedly, since it changes the evaluation context for each row, not for an aggregated total. To correctly get the sum of the ‘Remaining’ column for only Group01 and Group02 on the same PlanDate as the current row, you can rewrite your formula like this:
TA_Total_Column_Remaining =
VAR CurrentDate = 'Table'[PlanDate]
RETURN
CALCULATE(
SUM('Table'[Remaining]),
FILTER(
'Table',
'Table'[PlanDate] = CurrentDate &&
'Table'[Trade] IN {"Group01", "Group02"}
)
)
In this corrected version, the variable CurrentDate stores the row’s PlanDate, and the FILTER function checks for rows in the table that share that same date and belong to Group01 or Group02. The SUM inside CALCULATE then adds up the “Remaining” values for those matching rows. This ensures that for each row in your table, the calculated column correctly displays the total “Remaining” amount for both groups combined for that specific date.
Hi @AllanBerces
The error in your DAX formula occurs because of how you are using the variable CurrentGroup and the IN operator. In DAX, you can’t assign a logical expression like 'Table'[Trade] IN {"Group01", "Group02"} to a variable and then later compare a column directly to that variable — it results in an invalid data type or logical context error. Also, using CALCULATE inside a calculated column can behave unexpectedly, since it changes the evaluation context for each row, not for an aggregated total. To correctly get the sum of the ‘Remaining’ column for only Group01 and Group02 on the same PlanDate as the current row, you can rewrite your formula like this:
TA_Total_Column_Remaining =
VAR CurrentDate = 'Table'[PlanDate]
RETURN
CALCULATE(
SUM('Table'[Remaining]),
FILTER(
'Table',
'Table'[PlanDate] = CurrentDate &&
'Table'[Trade] IN {"Group01", "Group02"}
)
)
In this corrected version, the variable CurrentDate stores the row’s PlanDate, and the FILTER function checks for rows in the table that share that same date and belong to Group01 or Group02. The SUM inside CALCULATE then adds up the “Remaining” values for those matching rows. This ensures that for each row in your table, the calculated column correctly displays the total “Remaining” amount for both groups combined for that specific date.
Hi,
Share some data to work with and show the expected result. Share data in a format that can be pasted in an MS Excel file.
Hi,
I am not sure how the expected result looks like, but please try something like below, and please check whether it works.
Thank you.
TA_Total_Column_Remaining =
VAR CurrentDate =
TODAY ()
VAR CurrentGroup = { "Group01", "Group02" }
RETURN
CALCULATE (
SUM ( 'Table'[Remaining] ),
FILTER (
'Table',
'Table'[PlanDate] = CurrentDate && 'Table'[Trade] IN CurrentGroup
)
)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 35 | |
| 31 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 75 | |
| 72 | |
| 39 | |
| 35 | |
| 23 |