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
evolve_Tricia
Helper I
Helper I

Measure for summarizing sales by various starting dates but sum of the measures wrong

Hi, 

I have calculated the sales after unique permotions with certain discount_name (discounts can be repeatedly used). Here is the DAX for calculating sales within 48 hours after each promotion which summarized the revenue from "orders" table.  

Sales 48h = 
VAR date_online = MAX(performance[Date])
RETURN 
CALCULATE(
    SUM(orders[revenue]),
    DATESBETWEEN(orders[date],  date_online, date_online + 2)
)

 

Here is the table "performance"
evolve_Tricia_1-1599202638922.png

 

However, when I sum "sales 48 hours" , the total was wrong. Obviously it has taken the max dates of that month/quarter for calculating sums. For example, the total "sales 48h" for 2020-01 should be (982.38+9484.75+5951.44)=16418.57 not 32,303.20. But I tried modifying the DAX, none of them work 😑. Probably a separate measure calculated on a monthly basis is needed? 

evolve_Tricia_2-1599202713108.png

Any input is appreciated. 

 




 

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@evolve_Tricia 

have you tried

measure= sumx(value('performance'[date], Sales 48h)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@evolve_Tricia 

have you tried

measure= sumx(value('performance'[date], Sales 48h)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu 
Thank you for your response. I followed your logic and corrected my DAX as

SUMX(VALUES(performance[Date]), performance[Sales 48h]))

And it worked like a charm!!!! Thanks!  

@evolve_Tricia 

You are welcome.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@evolve_Tricia , Try like

 

Sales 48h =
VAR date_online = MAX(performance[Date])
RETURN
CALCULATE(
SUM(orders[revenue]),values(orders[date]), values(orders[promotion]),
DATESBETWEEN(orders[date], date_online, date_online + 2)
)

Sales 48h =
VAR date_online = MAX(performance[Date])
RETURN
sumx( orders,orders[date],orders[promotion] ,"_1"
CALCULATE(
SUM(orders[revenue]),
DATESBETWEEN(orders[date], date_online, date_online + 2)
),[_1])

@amitchandak 
Thanks for your prompt respons.

I got the same result from your first DAX. The second one didn't work because orders does not contains "promotion" column. But even if I use performance[promotions], the numbers were not the total of sales 48hr either 

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.