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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
vinaydavid
Helper III
Helper III

DAX Calculation

Hi All,

 

I am planning to plot the below data into a stacked bar graph.

With Week on the X-axis (values like Curr.wk, forecast, +1 wk.....+3wk).

And on Y-axis I want to plot Type (XX, YY, ZZ .....etc.,)

 

TypeCategoryWeekValueCapacity
XXAA+3 Week28/08/20205
XXAA+3 Week29/08/20205
XXAA+3 Week25/08/20205
XXAA+3 Week26/08/20205
XXAA+3 Week26/08/20205
XXAA+3 Week28/08/20205
XXBB+3 Week28/08/20203
XXCC+3 Week25/08/20202

 

The below is what I want to achieve using a DAX measure.

 

AA=6 (count of 'Value')/5 (Avg. of 'Capacity')=1.20
BB=1/3=0.33
CC=1/2=0.50
  =2.03
   
XX=2.03 


So that, I can show for week '+3 Week' as 2.03 for Type (Legend).

Thanks in advance!

 

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hello @vinaydavid ,

Please try the following measurement:

Measure =
IF (
    HASONEVALUE ( 'Table'[Category] ),
    CALCULATE (
        DIVIDE ( COUNTROWS ( 'Table' ), AVERAGE ( 'Table'[Capacity] ) ),
        ALLEXCEPT ( 'Table', 'Table'[Category] )
    ),
    SUMX (
        SUMMARIZE (
            'Table',
            'Table'[Category],
            "_a", CALCULATE (
                DIVIDE ( COUNTROWS ( 'Table' ), AVERAGE ( 'Table'[Capacity] ) ),
                ALLEXCEPT ( 'Table', 'Table'[Category] )
            )
        ),
        [_a]
    )
)

Capture1.PNG

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

Best regards

Dedmon Dai

amitchandak
Super User
Super User

@vinaydavid The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format?

 For Week vs Week data refer

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

 


Appreciate your Kudos.

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.