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
Anonymous
Not applicable

Clustered column chart for monthly % share for every year

Hi,

 

I am trying to recreate following excel chart in Power BI.

 

amitdarak_0-1653559878628.png

 

I have data in raw format. Logic is I want to see every year's monthly trend.
Aug-21 it will be 120/846 ie 14%, Sep-21 it will be 107/846 ie 13%.

Aug-20 it will be 79/1124 ie 7%,  Sep-20 it will be103/1124 ie 9% and so on.

 

I tried writing below dax but giving incorrect result.

 

perc_share = DIVIDE(CALCULATE(COUNT(data[claim_no]),
FILTER(data, data[status] in {"Settled", "Outstanding"})),
CALCULATE(COUNT(data[claim_no]),
ALLEXCEPT(data,data[year]),
data[status]in {"Settled", "Outstanding"}))

 

I also tried using ALL filter. But still unable to get required result.

 

Kindly help.

 

Amit Darak

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

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1653962778447.png

Here are the steps you can follow:

1. Create calculated column.

Year = YEAR('data'[claim_no])
Month = FORMAT('data'[claim_no],"mmm")

2. Create measure.

Measure =
var _group1=CALCULATE(COUNT('data'[claim_no]),FILTER(ALL(data),'data'[Year]=MAX('data'[Year])&&'data'[Month]=MAX('data'[Month])&&'data'[status] in {"Settled", "Outstanding"}))
var _group2=CALCULATE(COUNT('data'[claim_no]),FILTER(ALL(data),'data'[Year]=MAX('data'[Year])&&'data'[status]in {"Settled", "Outstanding"}))
return
DIVIDE(
    _group1,_group2)

3. Result:

vyangliumsft_1-1653962778452.png

 

Best Regards,

Liu Yang

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

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1653962778447.png

Here are the steps you can follow:

1. Create calculated column.

Year = YEAR('data'[claim_no])
Month = FORMAT('data'[claim_no],"mmm")

2. Create measure.

Measure =
var _group1=CALCULATE(COUNT('data'[claim_no]),FILTER(ALL(data),'data'[Year]=MAX('data'[Year])&&'data'[Month]=MAX('data'[Month])&&'data'[status] in {"Settled", "Outstanding"}))
var _group2=CALCULATE(COUNT('data'[claim_no]),FILTER(ALL(data),'data'[Year]=MAX('data'[Year])&&'data'[status]in {"Settled", "Outstanding"}))
return
DIVIDE(
    _group1,_group2)

3. Result:

vyangliumsft_1-1653962778452.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@Anonymous , if you have date using date table get total that year

example

Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year), "7/31"),"7/31"))

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),previousyear('Date'[Date],1,Year), "7/31")

 

or

 

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))

Helpful resources

Announcements
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.

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.