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
irnm8dn
Post Prodigy
Post Prodigy

Dax Calculation - Cost Per Thousand and Number Formatting

Trying to perform a calculation and having some challenges...which I think how Power BI is recognizing my data.

 

The calculation should be:

 

Budget, Divided by Cost Per Thousand * 1,000

 

My limitations are:

  • After import, I believe that Power BI is not recognizing Cost Per Thousand notr Budget in a proper format (see pic below) 
  • Screen Capture.PNG
    • The reason I think this, is that when I attempt the DAX statement using the New Measure Button in the ribbon, it does not give me the option to use these fields in my calculation.  i.e. Measure = DIVIDE( budget
  • Secondly, I have an additional column called Contract Rate.  One of the values is "<10,000" and I think I need to find an alternative as the special character is limiting my ability to identify this column as a "Whole Number".

 

All suggestions are welcome.

 

Thank you.

1 ACCEPTED SOLUTION

Hi @irnm8dn,

 

1. Use the formula below to add a calculate column in your table.

Column = DIVIDE('Master Rate Data'[Budget],'Master Rate Data'[Cost-Per-Thousand])*1000

2. Then you should be able to use the formula below to create new measure, then show it on the report.

messure = 
IF (
    HASONEFILTER ( 'Master Rate Data'[Product] )
        && HASONEFILTER ( 'Master Rate Data'[Budget] )
        && HASONEFILTER ( 'Master Rate Data'[Spend Level] ),
    MAX ( 'Master Rate Data'[Column] )
)

r1.PNGr2.PNG

 

Here is the modified pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

10 REPLIES 10

Your measure needs to be a calc column

MFelix
Super User
Super User

Hi @irnm8dn,

Yoir budget column is in the correct format that you can see because the epsilon sign. A measure is evaluated in the context of the cell evaluated in a dax formula, this.meaning that it take into.account if you are grouping the information for instance, its not only ar a row level. This means that to make your formula work you need to add some summarize formula try this.

Measur = DIVIDE (SUM(Table[Budget]), SUM(Table[Value]))

Don't know what is the value you are dividing by but when using a measure.you need to give.context to your.colums since the calculations csn be done at a row level or.group.level.

Regards,
MFelix

P.S. if any of the DAX experts see any error in my theorical explanation please correct me 🙂


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks @MFelix

 

I am thinking we are almost there, but that the DAX formula may not be entirely correct.

 

Let me write this as a word problem so we can look at all the inputs and we can discuss a proper DAX calculation.

 

Johnny has a $500 budget to purchase apples.  The cost for apples is $20 cost per thousand.  How many apples can Johnny buy based on his budget.  $500/$20*1000 = 25,000 apples.

 

Thanks for the help.

Hi @irnm8dn,

 

If that is the case then just multiply your cost per thousan by 1000 this should give you:

 

Measure = DIVIDE (SUM(Table[Budget]), SUM(Table[CostPerThousand])*1000)

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



I don't think it should be summing the CPM.  Despite getting a calculation - it's not working properly.

 

Any thoughts?

How do you ussualy do it with average value, max min?

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hello @MFelix.

 

Simply put I take the Budget (Customer Spend), divided by the CPM "constant" * 1,000....essentially it give me the total number of units a customer could purchase based on budget.

 

The CPM is a "constant".

If you're interested, and looking for a full picutre if what I am trying to do, this may help.  I have added some sample files, because I am tied in knots over this one.  Thanks your help. http://community.powerbi.com/t5/Desktop/Slicer-Behavior-on-Tiles/m-p/188227#M82778

 

 

 

Hi @irnm8dn,

 

1. Use the formula below to add a calculate column in your table.

Column = DIVIDE('Master Rate Data'[Budget],'Master Rate Data'[Cost-Per-Thousand])*1000

2. Then you should be able to use the formula below to create new measure, then show it on the report.

messure = 
IF (
    HASONEFILTER ( 'Master Rate Data'[Product] )
        && HASONEFILTER ( 'Master Rate Data'[Budget] )
        && HASONEFILTER ( 'Master Rate Data'[Spend Level] ),
    MAX ( 'Master Rate Data'[Column] )
)

r1.PNGr2.PNG

 

Here is the modified pbix file for your reference. Smiley Happy

 

Regards

@v-ljerr-msft

 

AMAZING!  Thank you so much.

 

One question, is there a way to make spend level formatted as a currency?  I belive the special characte of "<" is keeping me from doing this?

No.  The special character means the whole value gets treated as a string, not a numeric value.

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.