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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Two count calculation showing together in one measure

Capture1.PNG

With above data am trying to create a column  that contains two count calculation,

Count 1 =
CALCULATE(
COUNTROWS( myTable ),
myTable[endt] = 0,
FILTER( myTable, myTable[type] = "Cancel" || myTable[type] = "endt" )
)

 

Count 2 =
CALCULATE(
COUNTROWS( myTable ),
myTable[endt] > 0,
FILTER( myTable, myTable[type] = "new" || myTable[type] = "renewal" )
)

 

The condition was this...

1)Count for type where endt=0 for types(Cancel,endt)

2)Count for type where endt greater than 0 for types (new,renewal).

 

if 1 condition satisfy means count calculation based on that if not 2nd calcualtion wants to do...So do both calculation do based on conditions in one column output would be shown 

Is it possible? 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

I don't fully understand your explanation but you could try this measure

Count = 

VAR _Count1 = CALCULATE(COUNTROWS( myTable ), FILTER( myTable, (myTable[type] = "Cancel" || myTable[type] = "endt") && myTable[endt] = 0 ))

VAR _Count2 = CALCULATE(COUNTROWS( myTable ), FILTER( myTable, (myTable[type] = "new" || myTable[type] = "renewal") && myTable[endt] > 0 ))

RETURN

IF(SELECTEDVALUE(myTable[endt]) = 0, _Count1, _Count2)

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
v-kkf-msft
Community Support
Community Support

Hi @Anonymous ,

Try the following formula:

Measure = 
    var Count1 = 
        CALCULATE(
            COUNTROWS( 'Table' ),
            'Table'[endt] = 0,
            FILTER( 
                'Table', 
                'Table'[type] = "Cancel" || 'Table'[type] = "endt" 
            )
        )
    var Count2 = 
        CALCULATE(
            COUNTROWS( 'Table' ),
            'Table'[endt] > 0,
            FILTER( 
                'Table', 
                'Table'[type] = "new" || 'Table'[type] = "renewal" 
            )
        )
    var result = 
        IF(
            MAX('Table'[type]) = "Cancel" || MAX('Table'[type]) = "endt" ,
            "A",
            "B"
        )
    return 
        IF(
            result = "A",
            Count1,
            Count2
        )

v-kkf-msft_0-1616129599226.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

PhilipTreacy
Super User
Super User

Hi @Anonymous 

I don't fully understand your explanation but you could try this measure

Count = 

VAR _Count1 = CALCULATE(COUNTROWS( myTable ), FILTER( myTable, (myTable[type] = "Cancel" || myTable[type] = "endt") && myTable[endt] = 0 ))

VAR _Count2 = CALCULATE(COUNTROWS( myTable ), FILTER( myTable, (myTable[type] = "new" || myTable[type] = "renewal") && myTable[endt] > 0 ))

RETURN

IF(SELECTEDVALUE(myTable[endt]) = 0, _Count1, _Count2)

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


amitchandak
Super User
Super User

@Anonymous , No very clear to me.

 

You can have a third calcultion like

if(isblank([Count 1]), [Count 2], [Count 1])

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.