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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.