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

Dynamic Column calculation based on Slicer Selection

I'm fairly new to power bi but I've done some prior work in Tableau.  In my Tableau reports, I was able to create a calculated field (I called it "Period"), which, based on a dropdown selection, would translate a date into its date, week,  month, quarter, or year value.   I would then use the calculated field as the column header in their matrix.  

 

The end result is that by simply selecting daily/weekly/monthly/quarterly/yearly from a dropdown, the user would change the matrix to display data by the selected period breakdown.

 

Does anyone know how to do this in Power BI?

 

1 ACCEPTED SOLUTION
vanessafvg
Super User
Super User

@Elderin

 

Dragging any date into a visual will create a date hierarchy, as long as its a date format.

 

or alternatively it is best practise to create a date table and then you can also create your own hierarchies.

 

but to start simply drag your date that is in a date format onto your visual object and then you can toggle between the date without a hierarchy and the date with.  The default date  hiearchy is a y/q/m/d so if you want week its best to add a date table into your pbix and then create a relationship between your date and the date table.

 

this is one way of creating the date table

 

https://www.mattmasson.com/2014/02/creating-a-date-dimension-with-a-power-query-script/

in the picture below you can see i dragged my date onto my axis and it gives me the option to choose between the hierarchy and the date.

 


Capture.PNG

 

when you use the hierarchy you can use the drill down to navigate through the hierarchy you will find it in the top left of the visual.

 Capture.PNG





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
v-sihou-msft
Employee
Employee

@Elderin

 

In Power BI, it's not supported to directly translate the date part for a date. You need to create calculated columns and use DAX function to get those date parts.

 

If you want to have the different wise appeared on matrix header, you can populate a date hierarchy in New Matrix preview, and drill down to different level.

 

4.PNG

 

If you want to filter the data based on different level (day, month, quarter, etc), you can try custom visual Hierarchy Slicer.

 

Regards,

vanessafvg
Super User
Super User

@Elderin

 

Dragging any date into a visual will create a date hierarchy, as long as its a date format.

 

or alternatively it is best practise to create a date table and then you can also create your own hierarchies.

 

but to start simply drag your date that is in a date format onto your visual object and then you can toggle between the date without a hierarchy and the date with.  The default date  hiearchy is a y/q/m/d so if you want week its best to add a date table into your pbix and then create a relationship between your date and the date table.

 

this is one way of creating the date table

 

https://www.mattmasson.com/2014/02/creating-a-date-dimension-with-a-power-query-script/

in the picture below you can see i dragged my date onto my axis and it gives me the option to choose between the hierarchy and the date.

 


Capture.PNG

 

when you use the hierarchy you can use the drill down to navigate through the hierarchy you will find it in the top left of the visual.

 Capture.PNG





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




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.