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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

how to calculate return

Hi, all

 

I wonder why this is error

1EA = CALCULATE(count('Table'[itemlv2_lastlinkconsumerid]), 'Table'[dvc_total] = 1)

 

I want to show the number of devices by Device Type (=n_combination) in a table as shown below.
However, if you generate the measure value in the above equation, there will be an error occurs.
dvc_total is also a measure value.
I would appreciate it if you could let me know how to get it.

 

HUAM_0-1647243813861.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

total =
var _table=SUMMARIZE('Table','Table'[Id],'Table'[Dvcgroup],'Table'[n_combination],'Table'[cnt])
return
SUMX(FILTER( _table,[Id]=EARLIER([Id])&&[n_combination]=EARLIER([n_combination])),[cnt])

2. Result:

vyangliumsft_0-1647497808213.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

total =
var _table=SUMMARIZE('Table','Table'[Id],'Table'[Dvcgroup],'Table'[n_combination],'Table'[cnt])
return
SUMX(FILTER( _table,[Id]=EARLIER([Id])&&[n_combination]=EARLIER([n_combination])),[cnt])

2. Result:

vyangliumsft_0-1647497808213.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Greg_Deckler
Super User
Super User

@Anonymous You cannot use a measure directly in the filter parameter of CALCULATE, you have to wrap it with FILTER like:

1EA = CALCULATE(count('Table'[itemlv2_lastlinkconsumerid]), FILTER('Table','Table'[dvc_total] = 1))



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

May I ask you a question?

 

HUAM_0-1647246520420.png

 

how to calculate total?
I tried like

Total =
SUMX(
FILTER('Table',
[itemlv2_lastlinkconsumerid] =earlier([itemlv2_lastlinkconsumerid]) &&
[n_combination] =earlier([n_combination]) ),
[cnt])
but result is 9..

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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