cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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!:
Mastering Power BI 2nd Edition

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

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors