The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi,
I need a measure to calculate with conditions that
Count: Internal Site ID
Condition 1: Category = NDPd
Condition 2: Site Creation(NDPd/IPM) = blank
Result= 23
My try is below and not resulting 23. still showing 32,561 total count of Internal Site ID.
Pls fix and suggest any simpler and better measure.
Solved! Go to Solution.
Hi @jeongkim, Please try the below measure:
NDPd Site Creation =
CALCULATE(
COUNTROWS('Distinct - Master Data'),
'Distinct - Master Data'[Category] = "NDPd",
ISBLANK('Distinct - Master Data'[Site Creation(NDPd/IPM)])
)
Hi @jeongkim ,
You can achieve your goal by this DAX:
NDPd Site Creation =
VAR _filter =
FILTER(
'Distinct - Master Data',
'Distinct - Master Data'[Category] = "NDPd" &&
ISBLANK('Distinct - Master Data'[Site Creation(NDPd/IPM)])
)
RETURN
CALCULATE(
COUNT('Distinct - Master Data'[Internal Site ID]),
_filter
)
Here you go
VAR _filter =
FILTER (
'Distinct - Master Data',
'Distinct - Master Data'[Category] = "NDPd"
&& ISBLANK ( 'Distinct - Master Data'[Site Creation(NDPd/IPM)] )
)
RETURN
CALCULATE ( COUNTROWS ( 'Distinct - Master Data' ), _filter )
COUNTROWS - counts the number of rows in a table
COUNT - Counts the number of rows in the table where the specified column has a non-blank value
if there are no blanks in Internal Site ID column, the result will be the same
Hi @jeongkim ,
You can achieve your goal by this DAX:
NDPd Site Creation =
VAR _filter =
FILTER(
'Distinct - Master Data',
'Distinct - Master Data'[Category] = "NDPd" &&
ISBLANK('Distinct - Master Data'[Site Creation(NDPd/IPM)])
)
RETURN
CALCULATE(
COUNT('Distinct - Master Data'[Internal Site ID]),
_filter
)
This solution also works thanks!
Hi @jeongkim, Please try the below measure:
NDPd Site Creation =
CALCULATE(
COUNTROWS('Distinct - Master Data'),
'Distinct - Master Data'[Category] = "NDPd",
ISBLANK('Distinct - Master Data'[Site Creation(NDPd/IPM)])
)
It works thanks!
Hi @jeongkim
To achieve a distinct count filtered by _filter in DAX using CALCULATE, you must use the complete expression defined in the variable, rather than the variable itself. DAX variables are immutable. Once they're assigned a value, they cannot be altered or reassigned within the same expression.
any new dax suggestion pls?
Just use the expression from the _count variable in CALCULATE after your RETURN statement.
I dont' get it, can you write the code?
Here you go
VAR _filter =
FILTER (
'Distinct - Master Data',
'Distinct - Master Data'[Category] = "NDPd"
&& ISBLANK ( 'Distinct - Master Data'[Site Creation(NDPd/IPM)] )
)
RETURN
CALCULATE ( COUNTROWS ( 'Distinct - Master Data' ), _filter )
COUNTROWS - counts the number of rows in a table
COUNT - Counts the number of rows in the table where the specified column has a non-blank value
if there are no blanks in Internal Site ID column, the result will be the same