Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
JIli
Regular Visitor

The function expects a table expression for argument '', but a string or numeric expression was used

Hi there. With the following DAX I am trying to create two temporary tables: accive assets and inactive assets, and then  count all assets that do appear in "inactive" but not in "active" anymore (it is clear tham before they became inactive they were active at some point). I get the error: The function expects a table expression for argument '', but a string or numeric expression was used. Would be grateful for your help.

 

Churned assets =
VAR active_assets = CALCULATE(DISTINCT('CA'[AssetName]), FILTER ('CA','CA'[AssetState] = "Active") )
VAR inactive_assets = CALCULATE(DISTINCT('CA'[AssetName]), FILTER('CA','CA'[AssetState] = "Inactive") )

RETURN
    CALCULATE(
        COUNT('CA'[AssetName]),
       'CA'[AssetName] IN inactive_assets,
       'CA'[AssetName] NOT IN active_assets
        )
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @JIli ,

 

You are calculating in each of the variables a number and that cannot be used in the filter of the calculate try this instead:

Churned assets =
VAR active_assets = CALCULATETABLE(VALUES('CA'[AssetName]), FILTER ('CA','CA'[AssetState] = "Active") )
VAR inactive_assets = CALCULATETABLE(VALUES('CA'[AssetName]), FILTER('CA','CA'[AssetState] = "Inactive") )

RETURN
    CALCULATE(
        COUNT('CA'[AssetName]),
       'CA'[AssetName] IN inactive_assets,
       'CA'[AssetName] NOT IN active_assets
        )

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
mdaatifraza5556
Super User
Super User

Hi @JIli 

can you please try the below dax.

Churned Assets =
VAR active_assets =
                      FILTER (
                           VALUES ( 'CA'[AssetName] ),
                          CALCULATE ( MAX ( 'CA'[AssetState] ) = "Active" )
                     )
VAR inactive_assets =
                    FILTER (
                           VALUES ( 'CA'[AssetName] ),
                           CALCULATE ( MAX ( 'CA'[AssetState] ) = "Inactive" )
                   )
VAR churned_assets =
                    EXCEPT ( inactive_assets, active_assets )

RETURN
COUNTROWS ( churned_assets )

If this answers your questions, Kindly accept it as a solution and give kudos.

MFelix
Super User
Super User

Hi @JIli ,

 

You are calculating in each of the variables a number and that cannot be used in the filter of the calculate try this instead:

Churned assets =
VAR active_assets = CALCULATETABLE(VALUES('CA'[AssetName]), FILTER ('CA','CA'[AssetState] = "Active") )
VAR inactive_assets = CALCULATETABLE(VALUES('CA'[AssetName]), FILTER('CA','CA'[AssetState] = "Inactive") )

RETURN
    CALCULATE(
        COUNT('CA'[AssetName]),
       'CA'[AssetName] IN inactive_assets,
       'CA'[AssetName] NOT IN active_assets
        )

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.