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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
alexei7
Continued Contributor
Continued Contributor

DAX help

Hi guys,

 

I'm trying to create a DAX measure and hoping someone can help.

 

As a sample of some dummy date, my data is structured like this:

 

ReportDateProductCodeStoreStatusConcat Column
15/08/201810000ManchesterLive10000Live
15/08/201810000LondonLive10000Live
15/08/201810000BrightonLive10000Live
15/08/201815000LondonNot Live15000Not Live
15/08/201815000ManchesterNot Live15000Not Live
15/08/201817000LondonLive17000Live
16/09/201810000ManchesterLive10000Live
16/09/201810000LondonLive10000Live
16/09/201810000BrightonLive10000Live
16/09/201815000LondonLive15000Live
16/09/201815000ManchesterLive15000Live
16/09/201817000LondonLive17000Live
16/09/201820000LondonLive20000Live

 

What i'm trying to achieve is a metric to see in the previous month (i.e. September), how many new products there were.

A new product is defined as a product code which has its Status = "Live" and was not live in the month before (i.e. August) - either it didnt appear at all, or it had a different status.

 

My idea at resolving this was:

1) Create the concatenated column above joining the ProductCode and the Status

2) Creating a lookup column so that looks up from the concatenated column, to a filtered version of the above table for the month before (i.e. August)

3) A simple calculate formula, which would count the non-blank cells from the column created in step 2, filtered on previous month (i.e. September).

 

I have a date dimension which joins to the "ReportDate" column here. The data dimension includes two custom columns:

 

- "InlastMonth" (i.e. "Yes" for September 2018, "No" for all other dates)

- "TwoMonthsAgo" (i.e. "Yes" for August 2018, "No" for all other dates)

 

I'm stuck on step 2: "Creating a lookup column so that looks up from the concatenated column, to a filtered version of the above table for the month before ".

 

Can anyone help (either with this step, or with a better overall solution)?

 

Dummy model available here:

https://mega.nz/#!zLxxQaRY!FoJzxlXgGSxxxAecDP6iueBIps-0sIwTtYRIGxTWdMM

 

Thanks in advance

Alex

 

1 ACCEPTED SOLUTION

Hi @alexei7,

 

That case, please add a [Rank] column first.

Rank =
RANKX ( Products, Products[ReportDate],, ASC, DENSE )

Then, modify the formula in original post as below:

Column1 =
VAR previousstatus =
    LOOKUPVALUE (
        Products[Status],
        Products[ProductCode], Products[ProductCode],
        Products[Store], Products[Store],
        Products[Rank], Products[Rank] - 1
    )
RETURN
    IF ( previousstatus = BLANK () || previousstatus = "Not Live", "New", BLANK () )

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @alexei7,

 

I removed the relationship between data table and date dimension table. Then, create below calculated column:

Column1 =
VAR previousstatus =
    LOOKUPVALUE (
        Products[Status],
        Products[ProductCode], Products[ProductCode],
        Products[Store], Products[Store],
        Products[ReportDate].[MonthNo], Products[ReportDate].[MonthNo] - 1
    )
RETURN
    IF ( previousstatus = BLANK () || previousstatus = "Not Live", "New", BLANK () )

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
alexei7
Continued Contributor
Continued Contributor

Hi @v-yulgu-msft,

 

Thank you for your reply.

 

Unfortunately this doesnt work - I do need the relationship between the data table and the date dimension table for other calculations in my model/report.

 

The formula you've provided only takes account of the month number and not the previous month, so if i introduced some more data, i get the following incorrect result:

 

 incorrect data.png

 

Here the calculation is taking about only of the month number, so August 2019 is presumed to be before September 2018.

 

Thanks

Alex

Hi @alexei7,

 

That case, please add a [Rank] column first.

Rank =
RANKX ( Products, Products[ReportDate],, ASC, DENSE )

Then, modify the formula in original post as below:

Column1 =
VAR previousstatus =
    LOOKUPVALUE (
        Products[Status],
        Products[ProductCode], Products[ProductCode],
        Products[Store], Products[Store],
        Products[Rank], Products[Rank] - 1
    )
RETURN
    IF ( previousstatus = BLANK () || previousstatus = "Not Live", "New", BLANK () )

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
alexei7
Continued Contributor
Continued Contributor

I haven't tested this as the user changed requirements a little so I ended up solving this a different way.

 

Cheers for looking into it though.

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.