cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Regular Visitor

## DAX Measure to Create the Previous Date Sales

I have a measure that gives the sales over the given date in column B. I am trying to create another measure that would give me a results as in Column C (screenshot below).

Data Model:

The measure I have tried, but did not worked as expected.

CALCULATE([Sales_Measure],  FILTER(ALLSELECTED(DimDate), DimDate[Date] <  MAX(DimDate[Date])))
1 ACCEPTED SOLUTION
Super User

Hi,

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
5 REPLIES 5
Super User

Hi,

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Community Champion
``````=
CALCULATE (
LASTNONBLANKVALUE ( DimDate[DateKey], [Sales_Measure] ),
DimDate[DateKey] < MAX ( DimDate[DateKey] )
)``````

 Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! DAX is simple, but NOT EASY!
Super User

@PBI_enthusiast2 Try:

``````PD Measure =
VAR __DateKey = MAX('DimDate'[DateKey])
VAR __PDKey = MAXX(FILTER(ALL('DimDate'),[DateKey] < __DateKey)
VAR __Result = CALCULATE([Sales Measure], 'DimDate'[DateKey] = __PDKey)
RETURN
__Result``````

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Super User

Hi @Greg_Deckler and @CNENFRNL.  Could you share the way to solve this with the new WINDOW() and INDEX() functions.

Thank you.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Community Champion

No comments as I haven't mastered these newly introduced functions. I'm personally no fan for these funcs because they (seem to) sabotage the conciseness and elegance of "old-school" DAX funcs; IMHO they seem to be some replica of Tableau table calculation funcs.

 Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! DAX is simple, but NOT EASY!

Announcements

#### 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.

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors