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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
wsspglobal
Helper I
Helper I

Summarize data table that has various scenarios

Hi

I have the following table that has company data categorized in broader categoreis (labeled as capital letters) and sub-categories (capital letters and a number). There are 3 main scenarios in this table, 1) Category available, but SubCategory not available , 2) No information in a certain year 3) No information in all years. How do I summarize the number of companies in each scenario?

 

companyidFiscalYearCategorySubCategory
2221352011AA1
2221352011AA2
2221352011BB1
2221352011C 
2221352012DD1
2221352012DD2
2221352012FF1
2221352012FF2
2221352012FF3
2221352013AA1
2221352013BB1
2221352013BB2
2221352013GG1
2221352013GG2
2221352013LL1
2221352014  
2221352014  
2221352014  
2221352015CC1
2221352015CC2
2221352015CC3
2221352015CC4
2221352015BB1
2221352015BB2
2221352017AA1
2221352017AA2
2221352017AA3
2221352017BB1
2221352017BB2
2221352017BB3
2221352017C 
2221352017M 
2221352017L 
2221352017G 
2221352017HH1
2221352017HH3
2223272016A 
2223272016B 
2223272016C 
2223272016D 
2223272016E 
2223272016F 
2223272016G 
2240552011  
2240552011  
2240552012  
2240552012  
2240552013  
2240552013  
2240552014  
2240552014  
2240552015  
2240552015  
2240552016  
2240552016  
2240552017  
2240552017  
2240552018  
2240552018  
1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @wsspglobal ,

What you need is 3 measures as below

 

 

scenario 1 = CALCULATE(DISTINCTCOUNT('Table'[companyid]),filter('Table','Table'[Category]<>BLANK()&&'Table'[SubCategory]=BLANK()))
scenario 2 = 
CALCULATE(DISTINCTCOUNT('Table'[companyid]),FILTER('Table','Table'[Category]=BLANK()&&'Table'[SubCategory]=BLANK()),'Table'[FiscalYear]=2011)

 

 

 

scenario 3 = 
COUNTROWS (
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[companyid],
           "Condition", IF (
                CALCULATE (
                    COUNTROWS ( 'Table' ),
                    FILTER (
                        'Table',
                        'Table'[Category] = BLANK ()
                            && 'Table'[SubCategory] = BLANK ()
                    )
                )
                    <> COUNTROWS ( 'Table' ),
                FALSE (),
                TRUE ()
            )
        ),
        [Condition] = TRUE ()
    )
)

 

 

 

Then you will see as below:

113.png

 

For the related .pbix file,you can turn to the URL: https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-kellya_microsoft_com/EWEwraSQ_d9Emhnc_mUnFyc...

 

Hope this would help.

 

 

Best Regards,

Kelly

 

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @wsspglobal ,

What you need is 3 measures as below

 

 

scenario 1 = CALCULATE(DISTINCTCOUNT('Table'[companyid]),filter('Table','Table'[Category]<>BLANK()&&'Table'[SubCategory]=BLANK()))
scenario 2 = 
CALCULATE(DISTINCTCOUNT('Table'[companyid]),FILTER('Table','Table'[Category]=BLANK()&&'Table'[SubCategory]=BLANK()),'Table'[FiscalYear]=2011)

 

 

 

scenario 3 = 
COUNTROWS (
    FILTER (
        SUMMARIZE (
            'Table',
            'Table'[companyid],
           "Condition", IF (
                CALCULATE (
                    COUNTROWS ( 'Table' ),
                    FILTER (
                        'Table',
                        'Table'[Category] = BLANK ()
                            && 'Table'[SubCategory] = BLANK ()
                    )
                )
                    <> COUNTROWS ( 'Table' ),
                FALSE (),
                TRUE ()
            )
        ),
        [Condition] = TRUE ()
    )
)

 

 

 

Then you will see as below:

113.png

 

For the related .pbix file,you can turn to the URL: https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-kellya_microsoft_com/EWEwraSQ_d9Emhnc_mUnFyc...

 

Hope this would help.

 

 

Best Regards,

Kelly

 

amitchandak
Super User
Super User

Try

case 1 = calculate(count(table[companyid]),filter(table,not(isblank(Category)),isblank(SubCategory )))

case 2 = calculate(sumx(values(table[year],table[case 1])),filter(table,isblank[case 1]))
case 3 = calculate(sumx(table,table[case 1]),filter(table,isblank[case 1]))

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors