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
bc2022
Frequent Visitor

dynamically showing date range in Matrix

Hello,

 

Is there a way to dynamically adjust the date range based on the options listed in switch? My use case is I want to show metrics value within certain year range for different categories in matrix. The problem is each individual category may have different year range data. Currently, the report shows blank cells for those dates without value. So my goal is for below screenshot, the matrix only shows columns having data which start from column Jul-21.

 

1.png

 

The dax I used is :

test = SWITCH(
SELECTEDVALUE(Criteria[Criteria]),
"Option1", FORMAT(SUM(Rating[Value]),"General Number"),
"Option2",FORMAT(SUM(Rating[Value]),"0%"),
"Option3",FORMAT(SUM(Rating[Value]),"0%")
)

 

I can retrieve the start date and end date of each category dataset by using firstdate() and lastdate() function. But no sure how to incorporate them into above dax without breaking existing logics.

 

Many thanks.

 

2 REPLIES 2
amitchandak
Super User
Super User

@bc2022 , Try Field parameters, Make sure none of the measures using +0 or handling of blank or the below option should not be used 

 

Show item with No data new.png

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...
Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE

@amitchandak 

Thank you for your suggestion. 

I tried this approach but it seems it can't help with my issue. When I created a field parameter for the category field, it just gave me a category slicer without any available options (in my case, it did not list option1,option2, option3 which user can choose) . Also, it seems there is no place I can restrict the date range I mentioned in my question.

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.