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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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

@Anonymous 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

@Anonymous 

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!




@Anonymous 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?

Anonymous
Not applicable

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

 

Thank you!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.