Skip to main content
cancel
Showing results for 
Search instead 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

Reply
kasife
Helper V
Helper V

Comparing months with the same selected period

Hi people,

 

I'm having a little trouble getting the following result: I'd like to get the amount of leads for the current month, the previous month and the month before the previous one according to the period I select. I want to know what was the amount in the same period in these 3 months. How could I do this?
Here is the result I would like to get,

kasife_0-1690083186127.png

I am using the following measure and it is not working

 

    var atual = CALCULATE(DISTINCTCOUNT(_leads[Id]),_leads[Produtos com nome do Reaal]<>BLANK())
    var delta = DATEDIFF(max(d_calendario[Date]), min(d_calendario[Date]), MONTH)

    RETURN
  CALCULATE(
            atual,
            DATEADD(d_calendario_aux[Date],delta-1, MONTH)                    
             )
   

 

 

Here is my PBIX attached:

https://ufile.io/nl9o9xon

1 ACCEPTED SOLUTION
aj1973
Community Champion
Community Champion

Hi

DATEADD is meant to give the result in the selected date slicer. use these 3 dax 

atual = CALCULATE(DISTINCTCOUNT(_leads[Id]),_leads[Produtos com nome do Reaal]<>BLANK())
Atual -1 = CALCULATE([atual] , DATEADD(d_calendario[Date] , -1 , MONTH))

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

View solution in original post

5 REPLIES 5
aj1973
Community Champion
Community Champion

Hi @kasife 

Is this what you want to see?

aj1973_0-1690124679368.png

 

aj1973_0-1690127017517.png

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

@aj1973 thank you so muck for help.

Id like to see this:

kasife_0-1690136562172.png

I'm going to select periods, for example, from the 15th to the 20th of July, so I'll have the result from the 15th to the 20th of June and May as well.

Instead of using the calendar month, I would like to use dates

aj1973
Community Champion
Community Champion

Hi

DATEADD is meant to give the result in the selected date slicer. use these 3 dax 

atual = CALCULATE(DISTINCTCOUNT(_leads[Id]),_leads[Produtos com nome do Reaal]<>BLANK())
Atual -1 = CALCULATE([atual] , DATEADD(d_calendario[Date] , -1 , MONTH))

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

@aj1973 thank you so much. Its working.

aj1973
Community Champion
Community Champion

Welcome

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
Fabric Community Conference

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.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

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