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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
sobrien333
Regular Visitor

Measure to show # of days for two metrics to be equal

Hello, I have some data that tracks sales over time since a product launch date. I have created a 'New Quick Measure' for Running Total to track total sales from launch date. I am trying to create another measure that will show me how many days it took for 50% of my sales to come in; what we call 'doubling day', and the measure I created for that is:

.Doubling Day Line =
CALCULATE(SUM('Data'[Revenue])/2, ALL('Data'[Days Out]))

 

For example, if I were to sell 1 unit each day for a year I would have sold 365 units at the end of the year and it would have then taken me 183 days (182.5) to reach 50% of my sales (my doubling day). Each sale transaction in my data table also has 'days out' as a column to show days from product launch. My table looks something like this:

Sale DateLaunch DateUnits SoldDays Out
1/2/191/1/201911
1/3/191/1/201922
1/4/191/1/201913
1/5/191/1/201934
1/6/191/1/201915
1/7/191/1/201916
1/8/191/1/201927
1/9/191/1/201928
1/10/191/1/201919
1/11/191/1/2019310

Any idea how to create that measure?

1 ACCEPTED SOLUTION

Thanks Nick. I think I identified my problem. I dont' necessarily track sales by year, just overall (could span several years). So I didn't do the Total Yearly Sales measure, I just used a total sales measure. But I think that is what is causing the issue. How can I modify the Total Yearly Sales measure to not be limited to a single year?

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Attached the pbix file below, but..

  • Created a data table and related that to your main table. Set that as a date table
  • Wrote the following measures (assuming it was a total of yearly sales you are comparing)
Total Units Sold = SUM( Table1[Units Sold] )

Total Yearly Sales = 
IF(
    COUNTROWS( Table1) > 0,
 CALCULATE( [Total Units Sold], FILTER( ALL( DimCalendar), MAX( DimCalendar[Year])= DimCalendar[Year])))

50% of Yearly Sales = [Total Yearly Sales] *.50

Yearly Sales Running Total = 
 TOTALYTD( [Total Units Sold], DimCalendar[Date])

Date when 50% Crossed = 
CALCULATE( FIRSTDATE(DimCalendar[Date]), FILTER( ALL( DimCalendar),[Yearly Sales Running Total]>[50% of Yearly Sales]))

How Many Days = CALCULATE( DISTINCTCOUNT(Table1[Sale Date]), FILTER( ALL( DimCalendar), MAX(DimCalendar[Date]) >= DimCalendar[Date]))

Date When Crossed = if([Date when 50% Crossed] = max( DimCalendar[Date]),[How Many Days])



Final table, though you wouldnt  need or probably want all of them on the table, but I learned to always write out individual measures so they could be used later on if needbe and it's easier to change and troubleshoot:

Final Table.png

 

File:

https://1drv.ms/u/s!Amqd8ArUSwDS3BuleqFOpYwteQLw?e=Zea5ir

 

So I implemented each of the measures you created but for some reason my measure for Total Sales is calculating the same as a rolling (or year to date) total, but yours isn't. My formula is the same though. Any ideas?

Anonymous
Not applicable

be sure to set your date table as a date table

How to Mark as Date Table.png

Thanks Nick. I think I identified my problem. I dont' necessarily track sales by year, just overall (could span several years). So I didn't do the Total Yearly Sales measure, I just used a total sales measure. But I think that is what is causing the issue. How can I modify the Total Yearly Sales measure to not be limited to a single year?

This looks great, thanks! I'll work in this today.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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