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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Datatouille
Solution Sage
Solution Sage

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.