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
vfernandes
New Member

I need to compare selected date with prior date (daily, weekly, monthly)

I have this dynamic date selection on my dashboard in order to see the results (from a measure) aggregated by day, week, and month (pictures below).

 

diário.PNGsemanal.PNGmensal.PNG

To make this dynamic visual, I created the table below with all 3 groups of data in union. It is related to the calendar by day, and for the Weekly visual it takes the first day of the week, and for the month, the first day of the month.

 

Base Data.PNG

 relacionamento.png

 

Now I want to create 2 new visuals, but I don't know how to do it:
1 - Show the max date for the selected type

  • if it is selected daily it would show 17/04/2023 (today)
  • for weekly it would show 16/04/2023 (first day of the week)
  • for monthly it would show 01/04/2023 (first day of the month)

2 - Show the previous date for the selected type

  • if it is selected daily it would show 16/04/2023 (yesterday)
  • for weekly it would show 09/04/2023 (first day of the last week)
  • for monthly it would show 01/03/2023 (first day of the last month)

And it should change dynamicaly if I select another date on the chart

If I can create this 2 visuals, I can add a measure to compare both values and give me the delta to the previous value daily, weekly, monthly.

 

Sorry for the bad English and for the screenshots in Portuguese.

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @vfernandes 

According to your description, you want to get the current and previous date in the measure.

For your need , i think you can make your table max date as TODAY().

Here are the steps you can refer to .
This is my test data:

vyueyunzhmsft_0-1681876113804.png

We can create two measures like this:

First Need = 
MAX('Table'[Visual Date])
Second Need = var _slicer =MAX('Table'[Type])
return
IF(_slicer = "Daily" , [First Need]-1 ,IF(_slicer="Monthly" , EOMONTH([First Need],-2)+1 ,[First Need]-7))

 

Then we can get the date when you change the slicer.

vyueyunzhmsft_1-1681876161054.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @vfernandes 

According to your description, you want to get the current and previous date in the measure.

For your need , i think you can make your table max date as TODAY().

Here are the steps you can refer to .
This is my test data:

vyueyunzhmsft_0-1681876113804.png

We can create two measures like this:

First Need = 
MAX('Table'[Visual Date])
Second Need = var _slicer =MAX('Table'[Type])
return
IF(_slicer = "Daily" , [First Need]-1 ,IF(_slicer="Monthly" , EOMONTH([First Need],-2)+1 ,[First Need]-7))

 

Then we can get the date when you change the slicer.

vyueyunzhmsft_1-1681876161054.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

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.

Top Solution Authors