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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
manoj_0911
Advocate II
Advocate II

Assistance Needed: Implementing Date Period Parameter in Power BI

Hello Power BI Community,

 

I'm currently working on transitioning my reports from Tableau to Power BI, and I'm facing a challenge regarding the implementation of a dynamic date period parameter.

In Tableau, I had successfully created a table visual with a date period parameter that allowed users to select different time intervals such as month, day, hour, or sub-hour. Depending on the selected interval, the table displayed data at the corresponding level of granularity.

Here's how I implemented it in Tableau:

Date Period Parameter Calculation:
```
DATE PERIOD = CASE [PERIOD]
WHEN 'MONTH' THEN [MONTH]
WHEN 'DAY' THEN [DAY]
WHEN 'HOUR' THEN [HOUR]
WHEN 'SUB-HOUR' THEN [SUB-HOUR]
END
```

**Granularity Calculations:**
```
MONTH = LEFT(STR(DATENAME('month',[Ixn Subhour Date])),3)+"-"+RIGHT(DATENAME('year',[Ixn Subhour Date]),2)

DAY = STR(DATEPART('month',[Ixn Subhour Date]))+"/"+STR(DATEPART('day',[Ixn Subhour Date]))+"/"+STR(DATEPART('year',[Ixn Subhour Date]))

HOUR = STR(datetime( str(date([Ixn Subhour Date]))+" "+str(datepart('hour',[Ixn Subhour Date]))+":"+ '00' ))

SUB-HOUR = STR(datetime( str(date([Ixn Subhour Date]))+" "+str(datepart('hour',[Ixn Subhour Date]))+":"+ right("0"+str(int(datepart('minute',[Ixn Subhour Date])/30)*30),2) ))
```

I'm now looking to replicate this functionality in Power BI. Essentially, I need to create a parameter that allows users to select the granularity of the date period (month, day, hour, or sub-hour) and dynamically adjust the table visual accordingly.

Could you please provide guidance or step-by-step instructions on how to achieve this in Power BI? Any assistance or insights would be greatly appreciated.

Thank you in advance for your help!

Screenshot PERIOD PARAMETER.pngScreenshot MONTH.pngScreenshot DAY.pngScreenshot HOUR.pngScreenshot SUBHOUR.png

Best regards,
Manoj Prabhakar

2 REPLIES 2
Jonvoge
Solution Supplier
Solution Supplier

Hi Manoj.

 

You may leverage the feature called 'Field Parameters' for this in Power BI. It works for both Dimensions and Values, including Date Columns, but do note that the feature is still in preview: Let report readers use field parameters to change visuals (preview) - Power BI | Microsoft Learn

 

Field Parameters allow you to create a dynamic fields, which depending on selection in a filter, will display the selected dimensions/values. 

 

You begin by going to the Modeling Tab in Power BI Desktop, and select New Parameter -> Fields:

Jonvoge_0-1708433471647.png

 

Next, choose any number of Columns of any format you wish to add to the parameter:

Jonvoge_1-1708433563286.png

 

Finally, add a Slicer visual to your report with the Parameter as its Field, and put the Parameter into any other visualization you want. Here I added it to a table:

Jonvoge_2-1708433636698.png

 

Happy report building!



_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.

 

Hi @Jonvoge  Could you please share the above pbix file for my reference, Since I'm new to power bi I'm struggling on these things

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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