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
Anusha_Banda
Regular Visitor

Sales by Day, week and month

Hello all, 
I have a sales overview chart which shows the adsales etc on the selected date range. I now have a requirement where the client wants to see data by day, by week abd by monthly as available in amazon accounts (screenshot attached). 
I have created a filter measure (By day, By week and By month), however I am struck with how to proceed with the formula.
I am trying to use IF/Switch, for example,  

Filter_measure_sales = Switch (True(), 
SELECTEDVALUE('Filter Measure Sales'[Measure]) = "By Day", DATE(DAY(TODAY()),
SELECTEDVALUE('Filter Measure Sales'[Measure]) = "By Month", DATE(MONTH(TODAY()),
SELECTEDVALUE('Filter Measure Sales'[Measure]) ="By Week", DATE(WEEKDAY(TODAY()),
BLANK()))

Unsure how to correct the formulae, help me out  please !

Anusha_Banda_0-1675245402887.pngAnusha_Banda_1-1675245440012.pngAnusha_Banda_2-1675245638300.png

 

 

2 ACCEPTED SOLUTIONS
johnt75
Super User
Super User

You can use a field parameter to allow the user to choose the date granularity. There's a video explaining it at https://www.youtube.com/watch?v=KReYWx5NXYg and that also explains how to automatically adjust the date range for the chart dependent on which granularity is chosen

View solution in original post

v-yueyunzh-msft
Community Support
Community Support

Hi , @Anusha_Banda 

According to your description, you want to add a slicer to select the dimension showing on the x-axis.

This  is my test data:

vyueyunzhmsft_0-1675316502863.png

We can create a date table as a dimension table and create relationship between two tables.

Date = ADDCOLUMNS( 
CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date])),
"Year", YEAR ( [Date] ),
"Month", MONTH([Date]),
"Month_Name" , FORMAT([Date],"mmmm"),
"Week", weeknum([Date])& "week"
)

Then we can create a field parameter,like this:

vyueyunzhmsft_1-1675316801116.png

 

Then we can control the dimension on the x-asxi:

vyueyunzhmsft_2-1675316983971.pngvyueyunzhmsft_3-1675317026355.png

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

3 REPLIES 3
Anusha_Banda
Regular Visitor

Thank you for the quick response. It worked 🙂

v-yueyunzh-msft
Community Support
Community Support

Hi , @Anusha_Banda 

According to your description, you want to add a slicer to select the dimension showing on the x-axis.

This  is my test data:

vyueyunzhmsft_0-1675316502863.png

We can create a date table as a dimension table and create relationship between two tables.

Date = ADDCOLUMNS( 
CALENDAR(FIRSTDATE('Table'[Date]),LASTDATE('Table'[Date])),
"Year", YEAR ( [Date] ),
"Month", MONTH([Date]),
"Month_Name" , FORMAT([Date],"mmmm"),
"Week", weeknum([Date])& "week"
)

Then we can create a field parameter,like this:

vyueyunzhmsft_1-1675316801116.png

 

Then we can control the dimension on the x-asxi:

vyueyunzhmsft_2-1675316983971.pngvyueyunzhmsft_3-1675317026355.png

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

johnt75
Super User
Super User

You can use a field parameter to allow the user to choose the date granularity. There's a video explaining it at https://www.youtube.com/watch?v=KReYWx5NXYg and that also explains how to automatically adjust the date range for the chart dependent on which granularity is chosen

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.