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
vanessafvg
Super User
Super User

DAX Calculated % of a whole for Date

I have a calculated measure on my table which works perfectly to calculate each value as a % of the whole   Unit of Sale % = DIVIDE([Cummulative Units of Sale],CALCULATE([Cummulative Units of Sale],ALLSELECTED()))

 

 

However i want it to only calculate as a % of the month value i.e FY Month  so i changed it to this

 

Unit of Sale by Month % = DIVIDE([Cummulative Units of Sale],CALCULATE([Cummulative Units of Sale],FILTER('Date','Date'[TheDate]))) - this doesn't give the desires result it over inflates figures, so i obviously haven't a aclue what i am doing.

 

i actually want to slice it by the FY Year Month / Category but it doesn't like the string value in the filter where ive now put the date)

 

 

   
 FY M1FY M2 
Category 120%30%
Category 280%70%
 100%100%

 

what is the correct DAX code for this?





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!




2 REPLIES 2

Hi @vanessafvg

 

I think you should use the Category rather than the Date Table as a filter.

The 20% in your screenshot means : [Cummulative Units of Sale] represents 20% of (Category 1 + Category 2) in FY M1

(If I understood well?).

So you have to ignore the filter context caused by the Category. To do so, use the ALL function.

 

Try this:

[Cummulative Units of Sale All Cat] = Calculate( [Cummulative Units of Sale] , All(Category) )

And Then:

[Unit of Sale by Month %] = Divide ( [Cummulative Units of Sale] , [Cummulative Units of Sale All Cat] )

 

And let us know if it fits your requirements !

 

Equally, I suggest you break your measures into several parts ( As I did for [Unit of Sale by Month %] by creating, first and separately, [Cummulative Units of Sale All Cat] measure).

Using interim measures makes it easier to read, understand and update the measure(s).

 

By the way, prefer the term measures to "calculated measures" which could confuse your colleagues with "calculated columns". Measures used to be called "calculated fields" in Excel 2013 but {fortunately} Measures term came back in Excel 2016/Power BI Desktop.

i just changed what i have to category and it worked perfectly, i didnt use your statement so didn't test it but this is working great now!  

 

My measures are already broken up for easy for understanding, thanks for the help, since im slicing on date i dont need to create a separate measure for it!





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!




Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

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

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Kudoed Authors