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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ooctaviano
Frequent Visitor

% for measure

Hello

 

I have the following measure

 

Requested cost = CALCULATE(SUMX(Table,[Cost]*[Requested qty]))
 
The following measure looks in a table like this
 
ooctaviano_0-1624488063539.png

 

I just need adding the percetage to each of the items. In case of the order number the percetage should be 100%

 

Please advise

 

Omar Octaviano

1 REPLY 1
daxer-almighty
Solution Sage
Solution Sage

@ooctaviano 

 

Writing DAX code needs to follow some generally accepted rules (just like in Python) so that people are able to tell at a glance whether they see a measure or a column. From your code it's not at all clear whether [Cost] and [Requested qty] are measures or columns in the table.

 

I'd suggest reading this guide on DAX formatting rules: Rules for DAX Code Formatting - SQLBI and sticking to them religiously.

 

Please bear in mind that if you iterate a fact table through an aggregator (like SUMX, for instance) you should never invoke a measure in the second argument unless you want to 1) have a model that's agonizingly slow and/or 2) produce wrong figures in a somewhat random fashion. What's worse, you won't be even able to spot the problem.

 

Also, I anticipate that your model is a single-table one (if not, then ignore this remark but still watch the video). If you want to see what really bad things can happen in this case, please watch this video: (1) Auto-exist on clusters or numbers - Unplugged #22 - YouTube

 

To be able to write a good formula for what you want, you have to show the model and also say what you want to see at the grand total.

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.