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

Simple DAX function?

@Phil_Seamark - calling on you for your power BI wizard-like capabilities!

 

I am trying to write what I think would be a simple DAX function without an operation.

 

Two columns:

 

  • Customer Spend
  • Cost per Thousand

 

Calculation should be Customer Spend/Cost per Thousand * 1000 = Number of Units

 

Any suggestions...when I put an operation in front of the numerator and denominator the calculation works, but I get an incorrect answer.

 

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.

1 ACCEPTED SOLUTION

@irnm8dn I'm assuming you have a table with each row having a cost per thousand and a price and you are trying to calculate units for each row?  You need a calc column for something like that, unless you are trying to evaluate the expression for every row AND THEN summarize (i.e. sum, average etc.) in which case you could use a SUMX or similar function.

 

In any event, once you load your data to the data model, you can use DAX by right clicking on the table name and choosing Calculated Column.  Then write your function.

 

I would recommend doing simple calc columns like this in query editor if possible.  You will get better compression and performance of the data model if you add the column there rather than with DAX.

View solution in original post

4 REPLIES 4
vanessafvg
Super User
Super User

@irnm8dn 

what are you expecting?

measure = divide($500, ($20 * 1000))





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@irnm8dn I'm assuming you have a table with each row having a cost per thousand and a price and you are trying to calculate units for each row?  You need a calc column for something like that, unless you are trying to evaluate the expression for every row AND THEN summarize (i.e. sum, average etc.) in which case you could use a SUMX or similar function.

 

In any event, once you load your data to the data model, you can use DAX by right clicking on the table name and choosing Calculated Column.  Then write your function.

 

I would recommend doing simple calc columns like this in query editor if possible.  You will get better compression and performance of the data model if you add the column there rather than with DAX.

I think this should be a calc column not a measure.  Is that what you have tried?

I haven't tried that.  Can you offer some details on how to do, and the expression itself?

 

Thank you!

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.