Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hello,
I've made a calculated column for checking if each rows invoice is potentially double invoice or a unique invoice. It should return duplicate if its double and unique if its a new invoice.
Only when I set this code in DAX in a calcuated column it gives me the error that you cant use countrows and filter in a calculated column?
Does anybody know why this code won't work and what the solution is?
Thanks in advance.
Column =
VAR varCurrentValue1 = 'EZK TRX_019_Overzicht_facturen_2023_DEV'[Zakenpartner_naam]
VAR varCurrentValue2 = 'EZK TRX_019_Overzicht_facturen_2023_DEV'[Datum_factuur]
VAR varCurrentValue3 = 'EZK TRX_019_Overzicht_facturen_2023_DEV'[Factuur_nr]
VAR varCurrentValue4 = 'EZK TRX_019_Overzicht_facturen_2023_DEV'[Bedrag_factuur_EV]
VAR varInstances =
COUNTROWS(
FILTER(
'EZK TRX_019_Overzicht_facturen_2023_DEV',
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Zakenpartner_naam] = varCurrentValue1 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Datum_factuur] = varCurrentValue2 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Factuur_nr] = varCurrentValue3 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Bedrag_factuur_EV] = varCurrentValue4
)
)
var Result =
IF(
varInstances > 1,
"Duplicate",
"Unique"
)
RETURN
Result
Solved! Go to Solution.
The error you're encountering in your DAX calculated column is likely due to the use of the COUNTROWS and FILTER functions, which are not supported in calculated columns. These functions are used for row-level calculations in DAX, and calculated columns are computed at the time of data refresh, so they don't have access to row-level context.
Plz try this:
Potential Double Invoices =
VAR varCurrentValue1 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Zakenpartner_naam])
VAR varCurrentValue2 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Datum_factuur])
VAR varCurrentValue3 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Factuur_nr])
VAR varCurrentValue4 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Bedrag_factuur_EV])
VAR varInstances =
COUNTROWS(
FILTER(
'EZK TRX_019_Overzicht_facturen_2023_DEV',
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Zakenpartner_naam] = varCurrentValue1 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Datum_factuur] = varCurrentValue2 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Factuur_nr] = varCurrentValue3 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Bedrag_factuur_EV] = varCurrentValue4
)
)
RETURN
IF(
varInstances > 1,
"Duplicate",
"Unique"
)
The error you're encountering in your DAX calculated column is likely due to the use of the COUNTROWS and FILTER functions, which are not supported in calculated columns. These functions are used for row-level calculations in DAX, and calculated columns are computed at the time of data refresh, so they don't have access to row-level context.
Plz try this:
Potential Double Invoices =
VAR varCurrentValue1 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Zakenpartner_naam])
VAR varCurrentValue2 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Datum_factuur])
VAR varCurrentValue3 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Factuur_nr])
VAR varCurrentValue4 = SELECTEDVALUE('EZK TRX_019_Overzicht_facturen_2023_DEV'[Bedrag_factuur_EV])
VAR varInstances =
COUNTROWS(
FILTER(
'EZK TRX_019_Overzicht_facturen_2023_DEV',
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Zakenpartner_naam] = varCurrentValue1 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Datum_factuur] = varCurrentValue2 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Factuur_nr] = varCurrentValue3 &&
'EZK TRX_019_Overzicht_facturen_2023_DEV'[Bedrag_factuur_EV] = varCurrentValue4
)
)
RETURN
IF(
varInstances > 1,
"Duplicate",
"Unique"
)
User | Count |
---|---|
10 | |
9 | |
7 | |
4 | |
4 |