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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
MayurM
Regular Visitor

Getting count at summary level

Hi,

I have a table with raw data of contracts with details like contract ID, date, client name, bill, cost, etc. Sample data is given as  - 

MayurM_0-1715750206329.png

I created a measure to calculate margin. What I wanted was like this - 

MayurM_1-1715750383826.png

I was able to categorize the clients in margin brackets using a measure. But now I cannot use that measure in line or bar chart to give me the count of clients under each bracket for the year. I tried creating a second table but it will not be connected to existing slicers.

 

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

Hi @MayurM 

You can refer to the following solution.

The sample data is the same as you provided.

1.Create a new table.

Margin brackets =
VAR _add1 =
    ADDCOLUMNS ( GENERATESERIES ( 0, 0.9, 0.1 ), "EndNum", [Value] + 0.1 )
RETURN
    ADDCOLUMNS (
        _add1,
        "Range",
            FORMAT ( [Value], "percent" ) & "-"
                & FORMAT ( [EndNum], "percent" )
    )

vxinruzhumsft_0-1715823623307.png

2.I change the margin measure to the following.

Margin =
VAR a =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), [Client] IN VALUES ( 'Table'[Client] ) ),
        [Bill]
    )
VAR b =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), [Client] IN VALUES ( 'Table'[Client] ) ),
        [Cost]
    )
RETURN
    DIVIDE ( a - b, a )

3.Create a new measure to calculate the count.

Margin_Count =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Client] ),
    FILTER (
        'Table',
        [Margin] >= MAX ( 'Margin brackets'[Value] )
            && [Margin] < MAX ( 'Margin brackets'[EndNum] )
    )
)

4.Create the related visual ,e.g bar chart.

Put the following field to the viual.

vxinruzhumsft_1-1715823818242.png

 

Output

vxinruzhumsft_2-1715823828069.png

 

It can filtered by the date or other slicer.

vxinruzhumsft_3-1715823865381.png

Best Regards!

Yolo Zhu

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

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @MayurM 

You can refer to the following solution.

The sample data is the same as you provided.

1.Create a new table.

Margin brackets =
VAR _add1 =
    ADDCOLUMNS ( GENERATESERIES ( 0, 0.9, 0.1 ), "EndNum", [Value] + 0.1 )
RETURN
    ADDCOLUMNS (
        _add1,
        "Range",
            FORMAT ( [Value], "percent" ) & "-"
                & FORMAT ( [EndNum], "percent" )
    )

vxinruzhumsft_0-1715823623307.png

2.I change the margin measure to the following.

Margin =
VAR a =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), [Client] IN VALUES ( 'Table'[Client] ) ),
        [Bill]
    )
VAR b =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), [Client] IN VALUES ( 'Table'[Client] ) ),
        [Cost]
    )
RETURN
    DIVIDE ( a - b, a )

3.Create a new measure to calculate the count.

Margin_Count =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Client] ),
    FILTER (
        'Table',
        [Margin] >= MAX ( 'Margin brackets'[Value] )
            && [Margin] < MAX ( 'Margin brackets'[EndNum] )
    )
)

4.Create the related visual ,e.g bar chart.

Put the following field to the viual.

vxinruzhumsft_1-1715823818242.png

 

Output

vxinruzhumsft_2-1715823828069.png

 

It can filtered by the date or other slicer.

vxinruzhumsft_3-1715823865381.png

Best Regards!

Yolo Zhu

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

 

Thank you! It works...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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