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
Anonymous
Not applicable

Max date per customer per fiscal month

Hi,

 

Looking for a way to calculate the last visit date of customers and show it per fiscal months.

Have customers table with visit date.

Have Fiscal date table.

I want to create Last visited calculated table that will show for each customer max visit per fiscal month.

If one fiscal month visit was not made then the previous visit date should be taken.

Customers table  Fiscal Date table   Last visited calculated
CustomerVisited DateFiscal MonthYear CustomerFiscal MonthYearVisited
110.01.2019 1.01.201912019 11201910.01.2019
125.03.2019 2.01.201912019 12201910.01.2019
21.01.2019 3.01.201912019 13201925.03.2019
24.04.2019 4.01.201912019 14201925.03.2019
   5.01.201912019 15201925.03.2019
   6.01.201912019 ............
   7.01.201912019 113201925.03.2019
   ......... 2120191.01.2019
       2220191.01.2019
       2320191.01.2019
       2420194.04.2019
       ............
       21320194.04.2019

 

Thank you!

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous 

Attached sample file for your reference.You may check the measure in it.

Regards,

Community Support Team _ Cherie Chen
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

5 REPLIES 5
v-cherch-msft
Employee
Employee

Hi @Anonymous 

Attached sample file for your reference.You may check the measure in it.

Regards,

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

Hi @v-cherch-msft , thank you for this solution, this is brilliant, it worked just fine on my dataset! And fits my need almost perfectly. I have another column where the customer has a value as well. So if I filter e.g. April I want to know what was the sum of the latest available value for all customers. E.g. customer 1's last submitted value (say 100) was in march and customer 2 submitted a value in april that was 200. I want the result to be 300.

 

Is there any way to achive this? Thank you!

I continued and seachered the web for an answer. Alberto Ferrari @SQLBI nailed it:

https://www.sqlbi.com/articles/semi-additive-measures-in-dax/

Works great for me. The solution is quite different.

 

v-cherch-msft
Employee
Employee

Hi @Anonymous 

You may create a date table and make sure there's no relationship. Then create a measure like below:

Measure  =
VAR _date =
    CALCULATE (
        MAX ( Customers[Visited] ),
        FILTER (
            ALLSELECTED ( Customers ),
            Customers[Customer] = MAX ( Customers[Customer] )
                && MONTH ( Customers[Visited] ) = MONTH ( MAX ( 'Fixcal Date'[Date] ) )
                && YEAR ( Customers[Visited] ) = YEAR ( MAX ( 'Fixcal Date'[Date] ) )
        )
    )
RETURN
    IF (
        _date = BLANK (),
        CALCULATE (
            MAX ( Customers[Visited] ),
            FILTER (
                ALLSELECTED ( Customers ),
                Customers[Customer] = MAX ( Customers[Customer] )
                    && Customers[Visited] <= MAX ( 'Fixcal Date'[Date] )
            )
        ),
        CALCULATE (
            MAX ( Customers[Visited] ),
            FILTER (
                ALLSELECTED ( Customers ),
                Customers[Customer] = MAX ( Customers[Customer] )
                    && Customers[Visited] = _date
            )
        )
    )

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for your reply @v-cherch-msft !

 

I have implemented this in my project but the results are different. Not showing all months like on your picture.

 

lvd per customer.png

Where should I look?

 

Again, thank you for helping out!

 

All the best,

Mike

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.