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

Find % of category of the total in a month

Power BI newbie here 

 

I'm trying to calculate Percentage of each category in a given month and display via line graph to show the trend

 

Data is as below:

 

DateIDCategory
1/1/2021A001Standard
1/1/2021A002Standard
1/1/2021A003Emergency
1/4/2021A004Emergency
1/5/2021A005Standard
1/6/2021A006Standard
1/7/2021A007Emergency
1/8/2021A008Standard
2/1/2021A009Standard
2/2/2021A010Emergency
2/3/2021A011Standard
2/3/2021A012Standard
2/3/2021A013Emergency
2/6/2021A014Standard
2/7/2021A015Standard
2/7/2021A016Standard
2/9/2021A017Emergency
2/10/2021A018Standard
3/1/2021A019Standard
3/1/2021A020Emergency
3/1/2021A021Emergency
3/4/2021A022Standard
3/6/2021A023Emergency
3/6/2021A024Standard
3/7/2021A025Emergency

 

What is want to show is for each month (Jan, Feb, March etc..) what is the % of Standard of the total for that month and calculate the same for each month

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

Hi @Anonymous ,

 

Check the measure.

Measure = 
var _total = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Date].[Month]=SELECTEDVALUE('Table'[Date].[Month])))
var _category = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Date].[Month]=SELECTEDVALUE('Table'[Date].[Month])&&'Table'[Category]=SELECTEDVALUE('Table'[Category])))
return
_category/_total

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Check the measure.

Measure = 
var _total = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Date].[Month]=SELECTEDVALUE('Table'[Date].[Month])))
var _category = CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Date].[Month]=SELECTEDVALUE('Table'[Date].[Month])&&'Table'[Category]=SELECTEDVALUE('Table'[Category])))
return
_category/_total

2.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@Anonymous , Try a new measure like

 

divide(calculate(count(Table[ID]),filter(Table,Table[Category] = "Standard")),count(Table[ID]))

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.