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
mtrevisiol
Helper IV
Helper IV

How to create a column with the currently valid value and the value valid in the previous month

Hi everyone,

I have a table thar contains, for each product, the corresponding price list with the validity start date and the validity end date:

mtrevisiol_1-1645536824652.png

 

My goal is to create two columns:

- The first one, CurrentPrice, contains the currently valid price, which is €0,509 for the first product and €4,295 for the second one. Both prices have ValidityEndingDate = 31/12/1799, which means that the price is valid indefinitely;

- The second one, PreviousPrice, contains the price that was valid in the previous month (January 2022), which is (again) €0,509 for the first product and €4,277 for the second one.

 

Do you know how I can create the two columns? I think I should use ALLEXCEPT to calculate the values for each product, but I don't know how to compare dates to get what I want.

 

Here is the PBIX file: https://www.dropbox.com/s/he1q3z2s5n9jvss/Price%20Lists.pbix?dl=0

 

Thank you!

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Change that weird 1799/12/31 to a reasonable date such as 2099/12/31,

CNENFRNL_1-1645542202691.png

 

Excel worksheet formula is already powerful enough,

CNENFRNL_2-1645543740432.png


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!

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Change that weird 1799/12/31 to a reasonable date such as 2099/12/31,

CNENFRNL_1-1645542202691.png

 

Excel worksheet formula is already powerful enough,

CNENFRNL_2-1645543740432.png


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!

@CNENFRNL unfortunately there's a problem. The second measure returns the second most recent price, but my intent is to get the price that was valid one month ago (January 2022), at least for most days of the month, and not only the previous price. I hope I've explained myself.

That's great, thank you!

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.