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 August 31st. Request your voucher.

Reply
rrgeneral
Regular Visitor

How to create measures to calculate counts - Power BI desktop

New to Power BI desktop. Using data connection to Analysis Server Models in PBI Desktop (May 2019).

 

I want to create 2 measures COUNT1 and COUNT2 based on data below. I tried using the quick measures and could not figure out. Any input? I see that certain features such as calculated column are disabled in Power BI desktop when using Analysis server models.

 

TIA!

 

Sample data

 

Category

Count

@A1

1

@a2

2

@a3

3

F123

 

15

F123

20

 

Count of categories starting with @character@ = COUNT1 = 6

Count of categories named F123 = COUNT2 = 35

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @rrgeneral ,

If you are using Live Connection mode to connect to Analysis Service, you could not use Containstring() function to create measure.

Try to create measures like this:

Count 1 =
SUMX (
    FILTER ( 'Sheet1', SEARCH ( "@", 'Sheet1'[Category],, 0 ) > 0 ),
    [Count]
)
Count 2 =
CALCULATE ( SUM ( Sheet1[Count] ), 'Sheet1'[Category] = "F123" )

count.png

 

Best Regards,
Community Support Team _ 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

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @rrgeneral ,

If you are using Live Connection mode to connect to Analysis Service, you could not use Containstring() function to create measure.

Try to create measures like this:

Count 1 =
SUMX (
    FILTER ( 'Sheet1', SEARCH ( "@", 'Sheet1'[Category],, 0 ) > 0 ),
    [Count]
)
Count 2 =
CALCULATE ( SUM ( Sheet1[Count] ), 'Sheet1'[Category] = "F123" )

count.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jihwan_Kim
Super User
Super User

Hi, @rrgeneral 

Please try the below measures.

 

 

Picture2.png

 

Count named F123 =
CALCULATE( SUM('Table'[Count]), 'Table'[Category] = "F123")
 
Count starting with @ =
CALCULATE( SUM('Table'[Count]), CONTAINSSTRING('Table'[Category], "@*"))
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@rrgeneral , You can have two measure to need to do dynamic segmentation

 

Calculate([Count], Filter(Table, Table[Category] = "F123"))

 

or

 

Calculate([Count], Filter(Table, Search("@",Table[Category],,0)>0))

 

Refer for Dynaminc segmentation

 

https://www.daxpatterns.com/dynamic-segmentation/
https://radacad.com/grouping-and-binning-step-towards-better-data-visualization
https://youtu.be/CuczXPj0N-k

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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