cancel
Showing results for
Did you mean:

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

Helper V

## Percentage DAX Formula

Hi,

I want to create a percentage figure, i.e. x%, from two text fields.

It's basically calculating click through rate as a %. I've got a count of my audience for a mailshot in a column, a count of clicks in another column but I need to compute click through % line by line.  Help!?

Regards,

S

25 REPLIES 25
New Member
Hi! Try to create a measure like this and use FORMAT to get the percentage value.

BluePercentage =
var __bluePerc = DIVIDE([BlueNumber], [BlueNumber]+[GreenNumber])
return "The"&FORMAT(__bluePerc, "Percent") &" of the values are blue."
Impactful Individual

Sample data would help, not sure what you're trying to do but have you tried DIVIDE and format the resulting column to a Percentage?

New Column Name = Divide(Column A,Column B)

And then format New Column Name to percentage.

Frequent Visitor

Hi,

I tried to use Divide with Calculated column and got Blank value. Not sure why.

Impactful Individual

Not sure if it's late in the game but when you're trying the suggestions are you doing it on a separate pbix environment and not in your main data model?

I asked because usually when we ask for help we only take a portion of the data model and present to the community. when they do the solution it woluld work but when we apply it to the main data model it would...

Then there might be something from the data model that is causing this...

Helper V

Hi thanks for that. However, my values for Column A and Column B is text.  I am counting Column A and ColumnB but I want to do an inline percentage. See example below.  33 and 31 are counts of Text fields, I want to put an inline column to divide 31/33= 93.93%

Thanks.

Impactful Individual

Would you be able to post a dummy data keeping the table structure?  and also if possible the result desired.

Helper V

See attached. I have manually computed the % value in the pivot, I can't seem to do this in PowerBI.

All the columns are text, I am doing counts to get numeric values from them.  Thanks.

Community Champion

@SachinC

Hi, please try with these measures:

CountAudiences = COUNTA(Table1[Audience])

CountClicks = CALCULATE(COUNTA(Table1[Clicks]),FILTER(Table1,Table1[Clicks]<>BLANK()))

% = DIVIDE([CountClicks],[CountAudiences])

Lima - Peru
Helper V

Are you sure the CountClicks formula is correct? The FILTER bit doesn't seem to work.  Please help?  Thank you.

Community Champion

@SachinC

Please show me the result of CountClicks..

it gives you an error or the result is not the correct?

Lima - Peru
Helper V

Hi,

See attached. It's as if it's putting extra lines in for the same values and making % = 1.00.

Pls help.

Thanks

.

Community Champion

@SachinC

in my test file the CountClicks works Ok.

Let me see:

-When No have clicks is a blank row in this column? or have a space or something.  To discard this add a calculated column and put

Column=Len(ColumnwithClicks) the result to empty rows should be 0.

Lima - Peru
Helper V

I think I understand where you are coming from but I am lost.  Can you explain again please.  you are right, the values have blanks. Thanks.

Community Champion

@SachinC

I just need to discard that are empty values.

Because the CountClicks Dax filter the blanks so if you have 10 rows and 3 are empty the result should be 7. If the result is 10 then not are empty values.

Lima - Peru
Helper V

My CountClicks is this:  CountClicks = CALCULATE(COUNTA([Clicks]),FILTER(VPBI_Marketing_MailerStats,[clicks]<>BLANK()))

What do I modify it to please?

Community Champion

Trim and Clean the Column in the Query Editor and then Replace with null

Hope this helps!

Helper V

Didn't work.  Good effort though.

Employee

Hi @SachinC,

It's weird, I am unable to reproduce why you get the error result. Could you please share your .pbix file for further analysis?

Best Regards,
Angelia

Helper V

Unfortunately there's a lot of confidential data in my PBIX file. How else can you help me please? Thanks.

Helper V

Hi, I've managed to anonymise the data. How do I upload an Excel sheet please?