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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

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

6 REPLIES 6
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!




@evolve_Tricia , try like

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


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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
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])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.