Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
30 | |
13 | |
11 | |
9 | |
6 |