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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jppuam
Helper V
Helper V

Count metric into intervals

Hello,

i'm trying to count the metrics that fits the intervals correspondent.

For ex: i've a customer table with intervals of growth:

top clients : >40%

medium clients : >20% and <40%

low clients : >5% and <20%

bad clients : <5%

 

and i've another table that has the clients ID and the value of growth.

 

I want to make a bar chart with the intervals field in the X Axis, and i want to count the number of clients with the % growth in each interval.

 

How can i do this ?

 

Thank you,

jppuam

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@jppuam

Is this what you want?

Column = SWITCH(true(),'Table (2)'[value of growth]>0.4, "top clinets",'Table (2)'[value of growth]>0.2,"middle clinets",'Table (2)'[value of growth]>0.05,"low clients","bad clinets")

1.png2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

v-rzhou-msft
Community Support
Community Support

Hi @jppuam 

If you want to achieve your goal by measure, you may try my way.

I build two tables like yours Customer Table and Growth Table.

Measure:

 

Measure = 
VAR _bad =
    CALCULATE ( COUNT ( 'Table'[ID] ), FILTER ( 'Table', 'Table'[Growth] <= 0.05 ) )
VAR _low =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER ( 'Table', 'Table'[Growth] > 0.05 && 'Table'[Growth] <= 0.2 )
    )
VAR _medium =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER ( 'Table', 'Table'[Growth] > 0.2 && 'Table'[Growth] <= 0.4 )
    )
VAR _top =
    CALCULATE ( COUNT ( 'Table'[ID] ), FILTER ( 'Table', 'Table'[Growth] > 0.4 ) )
RETURN
    SWITCH (
        MAX ( 'Custom Table'[Category] ),
        "bad clients", _bad,
        "low clients", _low,
        "medium clients", _medium,
        _top
    )

 

Then build a bar chart or a column chart, add Interval of growth into Axis , Category into Legend and Measure into Value.

Result is as below.

2.png

You can download the pbix file from this link: Count metric into intervals

 

Best Regards,

Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @jppuam 

If you want to achieve your goal by measure, you may try my way.

I build two tables like yours Customer Table and Growth Table.

Measure:

 

Measure = 
VAR _bad =
    CALCULATE ( COUNT ( 'Table'[ID] ), FILTER ( 'Table', 'Table'[Growth] <= 0.05 ) )
VAR _low =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER ( 'Table', 'Table'[Growth] > 0.05 && 'Table'[Growth] <= 0.2 )
    )
VAR _medium =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER ( 'Table', 'Table'[Growth] > 0.2 && 'Table'[Growth] <= 0.4 )
    )
VAR _top =
    CALCULATE ( COUNT ( 'Table'[ID] ), FILTER ( 'Table', 'Table'[Growth] > 0.4 ) )
RETURN
    SWITCH (
        MAX ( 'Custom Table'[Category] ),
        "bad clients", _bad,
        "low clients", _low,
        "medium clients", _medium,
        _top
    )

 

Then build a bar chart or a column chart, add Interval of growth into Axis , Category into Legend and Measure into Value.

Result is as below.

2.png

You can download the pbix file from this link: Count metric into intervals

 

Best Regards,

Rico Zhou

 

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

ryan_mayu
Super User
Super User

@jppuam

Is this what you want?

Column = SWITCH(true(),'Table (2)'[value of growth]>0.4, "top clinets",'Table (2)'[value of growth]>0.2,"middle clinets",'Table (2)'[value of growth]>0.05,"low clients","bad clinets")

1.png2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

Hello Amittchandak,

i'm continuing not understand how to do it.

Can i sent you an email with the pbix and try to explain better what i need to do ?

 

thank you,

jppuam

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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