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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ariana_night
Frequent Visitor

Simplifying DAX for POS Data

Hello,

I have been asked to revise some current measures that someone created before my time. I have spent the last 4 days researching and rewriting the DAX and nothing works. I have to revise measures for: this month, last month, this quarter, last quarter. 

Please see the current DAX measures below for reference. Any feedback on minimizing the amount of DAX that is used in these measures is GREATLY APPRECIATED. 

 

last mo POS = 
VAR this_wk = CALCULATE(MAX('POS Weekly All Accounts Sales'[Week End Date]))

RETURN
CALCULATE(
'POS Weekly All Accounts Sales'[POS Units Sold], 
'Calendar'[Week End Date] = this_wk -28
|| 'Calendar'[Week End Date] = this_wk - 35
|| 'Calendar'[Week End Date] = this_wk - 42
|| 'Calendar'[Week End Date] = this_wk - 49
)


this mo POS = 
VAR this_wk = CALCULATE(MAX('POS Weekly All Accounts Sales'[Week End Date]))

RETURN 
CALCULATE(
'POS Weekly All Accounts Sales'[POS Units Sold], 
'Calendar'[Week End Date] = this_wk
|| 'Calendar'[Week End Date] = this_wk - 7
|| 'Calendar'[Week End Date] = this_wk - 14
|| 'Calendar'[Week End Date] = this_wk - 21
)


last Q POS = 
VAR this_wk = CALCULATE(MAX('POS Weekly All Accounts Sales'[Week End Date]))

RETURN
CALCULATE(
'POS Weekly All Accounts Sales'[POS Units Sold], 
'Calendar'[Week End Date] = this_wk - 91
|| 'Calendar'[Week End Date] = this_wk - 98
|| 'Calendar'[Week End Date] = this_wk - 105
|| 'Calendar'[Week End Date] = this_wk - 112
|| 'Calendar'[Week End Date] = this_wk - 119
|| 'Calendar'[Week End Date] = this_wk - 126
|| 'Calendar'[Week End Date] = this_wk - 133
|| 'Calendar'[Week End Date] = this_wk - 140
|| 'Calendar'[Week End Date] = this_wk - 147
|| 'Calendar'[Week End Date] = this_wk - 154
|| 'Calendar'[Week End Date] = this_wk - 161
|| 'Calendar'[Week End Date] = this_wk - 168
|| 'Calendar'[Week End Date] = this_wk - 175
)


this Q POS = 
VAR this_wk = CALCULATE(MAX('POS Weekly All Accounts Sales'[Week End Date]))

RETURN 
CALCULATE(
'POS Weekly All Accounts Sales'[POS Units Sold], 
'Calendar'[Week End Date] = this_wk
|| 'Calendar'[Week End Date] = this_wk - 7
|| 'Calendar'[Week End Date] = this_wk - 14
|| 'Calendar'[Week End Date] = this_wk - 21
|| 'Calendar'[Week End Date] = this_wk - 28
|| 'Calendar'[Week End Date] = this_wk - 35
|| 'Calendar'[Week End Date] = this_wk - 42
|| 'Calendar'[Week End Date] = this_wk - 49
|| 'Calendar'[Week End Date] = this_wk - 56
|| 'Calendar'[Week End Date] = this_wk - 63
|| 'Calendar'[Week End Date] = this_wk - 70
|| 'Calendar'[Week End Date] = this_wk - 77
|| 'Calendar'[Week End Date] = this_wk - 84
)

 

3 REPLIES 3
ariana_night
Frequent Visitor

Hi:

The table looks like this (using Month over Month example):

 

This Month and Last Month POS Units sold in 2 different columns. I thought using  DATESBETWEEN or DATESINPERIOD would shorten the DAX but either it does not work or I am not using them correctly. As far as relationships, the 'pos weekly all accounts [week end date]' and 'calendar [week end date]' connected. I hope I answered your question.

ariana_night_0-1653585969977.png

 

Hi @ariana_night ,

 

Please try to create your measures like so:

last mo POS =
CALCULATE (
    'POS Weekly All Accounts Sales'[POS Units Sold],
    DATESINPERIOD ( 'Calendar'[Date], MAX ( 'Calendar'[Date] ), - 1, MONTH )
)

 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Whitewater100
Solution Sage
Solution Sage

Hi:

Do you have your pos results with a date field in separate table? If you have a separate date table, all those calculations are very straightforward. If you feel like sharing an example I will check it out a bit later today. Thanks..

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.