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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bombom
Helper I
Helper I

DAX Measure calculated total of month repeats everyday

Hello! I want to create a DAX measure so it calculates the total sales of the month a this number will appear on the graph for everyday of the calculated month. Desirable result is filled with yeloow. Any help please?

 

The formulas of staked metrics look like this:

 

Revenue_staked = CALCULATE(SUMX(AW_Sales, AW_Sales[OrderQuantity] * RELATED(AW_Product_Lookup[ProductPrice])),DATESMTD(AW_Calendar_Lookup[Date]))
 
Revenue_staked_prev_month = CALCULATE([Revenue_staked], DATEADD(AW_Calendar_Lookup[Date],-1,MONTH))
 
Profit_staked = CALCULATE(SUMX(AW_Sales, AW_Sales[OrderQuantity] * RELATED(AW_Product_Lookup[ProductPrice])),DATESMTD(AW_Calendar_Lookup[Date])) - CALCULATE(SUMX(AW_Sales, AW_Sales[OrderQuantity] * RELATED(AW_Product_Lookup[ProductCost])),DATESMTD(AW_Calendar_Lookup[Date]))

 

изображение_2022-11-02_211141529.png

1 ACCEPTED SOLUTION

@bombom 
Hi, I strongly recommend using the latest version, howver if that's not possible try this trick:

Sales MTD Fix = 
CALCULATE(
    [Sales MTD],
    TREATAS(ENDOFMONTH('Calendar'[Date]),'Calendar'[Date]))

vojtechsima_2-1667474006312.png

 

 

View solution in original post

5 REPLIES 5
vojtechsima
Memorable Member
Memorable Member

Hi, @bombom ,
So you can play with it like this:

If you select your visual, you can click this button as shown, and add constant line by Field.

vojtechsima_0-1667418082602.png

The field would be the sum in month, for example something like this (Day = Day in Month):

Sales MTD = TOTALMTD([Sales], 'Calendar'[Date], ALLSELECTED('Calendar'[Day]))

Then it could look like this:

vojtechsima_1-1667418127980.png

 

 

Thank you @vojtechsima for reaching my question!

I've tried to create a constant line, but, unfortunatelly, I couldn't find the field called Data label. Looks like it's due to I'm using old version of PBI Dec 2020, cause I'm using Windows 7. And I've tried to use a formula alone, with out a constant line, and so this formula calculated cumulative total from the first till the last day, like all another lines.

 

Maybe there any option, like in SQL's window functions, to make calculation inside DAX to sum sales over  partition by month and as a result it will duplicate the same total amount for each day of the calculated month?

 

bombom_0-1667424716175.pngbombom_1-1667424766780.pngbombom_2-1667424839722.png

 

@bombom 
Hi, I strongly recommend using the latest version, howver if that's not possible try this trick:

Sales MTD Fix = 
CALCULATE(
    [Sales MTD],
    TREATAS(ENDOFMONTH('Calendar'[Date]),'Calendar'[Date]))

vojtechsima_2-1667474006312.png

 

 

@vojtechsima 

 

Everything worked! Thank you so much sir! We did it

 

bombom_0-1667546405354.png

 

Happy to help, my man. @bombom 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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