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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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