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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Create a measure to calculate percent for multi group

Hi everyone,

 

I has a table below: 

hoanganhep_1-1640859305345.png

To calculate percent like table below: 

 

hoanganhep_0-1640859209345.png

 

Normally I will create many Measure for each "Source" like below:

%Internet/Website = DIDIVE(Calculate(Count('Table'[id]), 'Table'[Source] = "Internet/Website"), Count('Table'[id]),0)

%Friend = DIDIVE(Calculate(Count('Table'[id]), 'Table'[Source] = "Friend"), Count('Table'[id]),0)

........

If i have 10 Sources --> need create 10 measures to calculate percent for each.  So, have any solution for create only 1 measure to calculate percent for each "Source" ? 

 

Thank you for reading. 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), allselected()),0 )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

@Anonymous , in that case try like

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), allselected(Table[Sources])),0 )

 

or

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), removefilter(Table[Sources])),0 )

 

or

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), filter(allselected(Table),Table[Date] =max(Table[Date]) )) ,0 )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), allselected()),0 )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak It work, but I have one more question. 

 

When I applied it with a column group by Date, the results like below pictures:

hoanganhep_0-1640861162574.png

 

With column: No.50.....

Total in this column is 23, marketing campaign = 7 --> % should be 7/23 *100. But now, It will divide to total is 97.

Any solution for this case sir? 

@Anonymous , in that case try like

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), allselected(Table[Sources])),0 )

 

or

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), removefilter(Table[Sources])),0 )

 

or

 

Divide(Count('Table'[id]),Calculate(Count('Table'[id]), filter(allselected(Table),Table[Date] =max(Table[Date]) )) ,0 )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Thank you sir. I got it 

 

hoanganhep_0-1640863389616.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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