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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count of calculated value in a hierarchy

Hi!

 

I have a table with some staff training information:

 

training_table

Staff NameTechnologySub-TechnologyTraining Level
RichardSoftwareSoftware A1
RichardSoftwareSoftware B3
RichardHardwareHardware A4
RichardHardwareHardware B4
DuilioSoftwareSoftware A2
DuilioSoftwareSoftware B5
DuilioHardwareHardware A1
DuilioHardwareHardware B2

 

now, I need to compute some measure that provides the count of staff members by training level.

To achieve this task I built a series of measures for each sub-level of technology, since it's fairly easy to count unfilteredrows:

 

Level 1 Sub = CALCULATE(COUNTROWS(training_table),'training_table'[Training Level] = 1)

...

Level 5 Sub = CALCULATE(COUNTROWS(training_table),'training_table'[Training Level] = 5)

 

but when it comes to the technology level, it gets rough: I tried to group and summarize the table, but it seems very difficult to get a count of filtered grouped table by the average value of a calculated column. Moreover, I don't actually know if is it possible to build a measure that can return the number of staff member per level that can work both for technology and sub-technolgy.

 

edit: the training level of technology level is the rounded up average of sub-technology levels.

 

thank you for the help!

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

I'm not sure whether it is what you need, but you can try these Measures.

 

Level Count by Sub-Tech =

CALCULATE (

    COUNT ( training_table[Training Level] ),

    FILTER (

        ALLEXCEPT ( training_table, training_table[Sub-Technology] ),

        training_table[Training Level] = MAX ( training_table[Training Level] )

    )

)

 

Avg Level Count by Tech =

VAR _value =

    SUMMARIZE (

        training_table,

        "avg",

            AVERAGEX (

                VALUES ( training_table[Sub-Technology] ),

                [Level Count by Sub-Tech]

            )

    )

RETURN

    ROUND ( _value, 0 )

 

The result looks like this:

v-cazheng-msft_0-1619517513131.png

 

For more details, you can refer the attached pbix file.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? 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-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

I'm not sure whether it is what you need, but you can try these Measures.

 

Level Count by Sub-Tech =

CALCULATE (

    COUNT ( training_table[Training Level] ),

    FILTER (

        ALLEXCEPT ( training_table, training_table[Sub-Technology] ),

        training_table[Training Level] = MAX ( training_table[Training Level] )

    )

)

 

Avg Level Count by Tech =

VAR _value =

    SUMMARIZE (

        training_table,

        "avg",

            AVERAGEX (

                VALUES ( training_table[Sub-Technology] ),

                [Level Count by Sub-Tech]

            )

    )

RETURN

    ROUND ( _value, 0 )

 

The result looks like this:

v-cazheng-msft_0-1619517513131.png

 

For more details, you can refer the attached pbix file.

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Anonymous
Not applicable

That was it!

Thank you!

amitchandak
Super User
Super User

@Anonymous , can you share the expected output?

Anonymous
Not applicable

Sure!

 

I need to produce two stacked graphs both with number of sfaff per training level. lets say that we have 9 people in the staff:

 

jalucchi_0-1619092446242.png

 

where level of technology level is the rounded up average of the sub-techonology values

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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