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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
CJ_96601
Helper V
Helper V

Measure - If then else

Can someone help me to calculate each record with F as 2 count and M as one count, please refer below. 

 

Record     
      
F     
F     
F     
F     
M     
M     
M     
      
Total count 11    
      
Note:  Each record with F is equivalent to 2 and M is equivalent to 1 
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @CJ_96601 ,

I have crate an index column first in query editors to count conveniently.

Then you can create a measure like this:

Total count =
CALCULATE (
    COUNT ( 'Table'[Record] ),
    FILTER ( 'Table', 'Table'[Record] = "F" )
) * 2
    + CALCULATE (
        COUNT ( 'Table'[Record] ),
        FILTER ( 'Table', 'Table'[Record] = "M" )
    )

You will get the result:

total count.png

 

Here is the demo, please try it:

PBIX 

 

Best Regards,
Yingjie Li

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

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @CJ_96601 ,

I have crate an index column first in query editors to count conveniently.

Then you can create a measure like this:

Total count =
CALCULATE (
    COUNT ( 'Table'[Record] ),
    FILTER ( 'Table', 'Table'[Record] = "F" )
) * 2
    + CALCULATE (
        COUNT ( 'Table'[Record] ),
        FILTER ( 'Table', 'Table'[Record] = "M" )
    )

You will get the result:

total count.png

 

Here is the demo, please try it:

PBIX 

 

Best Regards,
Yingjie Li

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

Thanks. it works as per my requirements

amitchandak
Super User
Super User

@CJ_96601 


you can have column like this and sum
new Column = If(Table[Record]="F",2,1)
or

sumx(values(Table[Record]),If(Table[Record]="F",2,1))
or
sumx(selectcolumns(Table,"ID",Table[record],"_sum",If(Table[Record]="F",2,1)),[_sum])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks.

 

I want to count the records as follows:

 

   F

   F

   M

 

Based on the below sample.  Total count is 5

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors