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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
PowerNewBI22562
New Member

How to calculate the count of a flag measure I have created?

I have a table as follows: 

Header1Header2Flag
Q123CL1
Q132GL(camp)0
Q321GL1
Q231CL (camp)0
Q312

CL

1
Q112GL1

 

I have created a "Flag" measure based on "Header2" column. So, only for CL and GL, the flag will be 1, else it will 0. 

Now I want to sum the "Flag" measure so that it will give me a count of total CL and GL. How do I do that? 

So far I have done the following and nothing has worked: 

1. exclude test = SUMX(VALUES(Table[Header2], if([Flag]=1)))

2. exclude test = CALCULATE(DISTINCTCOUNT(('Table'[Header1]), FILTER('Table', 'Table'[Flag]=1)))

3. exclude test = CALCULATE(COUNT(Table[Header1]), KEEPFILTERS(Table[Flag]=1))

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

To your Table visual, drag the Header 2 field.  Write this measure

Measure = SUMX('Table',[Flag])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@PowerNewBI22562 ,

Sumx(filter(Summarize(Table, Table[Header 1], Table[Header 2], "_1", [Flag]),[Flag] =1) , [Header 1])

 

or

 

countrows(filter(Table, Table[Header 2] in {"CL", "GL"}) )

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.