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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
djallarii
Helper I
Helper I

How can I count the values in the selected field of a field parameter?

I have a field parameter created for use in a line chart to display data on the x-axis by calendar quarter, month, week, or day.

 

Date Axis Display = {
    ("Quarter", NAMEOF('v_dim_date'[calendar_year_qtr]), 0),
    ("Month", NAMEOF('v_dim_date'[calendar_year_mth]), 1),
    ("Week", NAMEOF('v_dim_date'[calendar_year_wk]), 2),
    ("Day", NAMEOF('v_dim_date'[calendar_day]), 3)
}
 
I see that I can change a field parameter from "Show selected field" to "Show selected values of field" and it's that list of values I would like to count, the "selected values of field."
 
For example, using time period Jan 1, 2022 to Dec 31, 2022, counting the selected values of each field paramater option should give me the following results:
Quarter = 4
Month = 12
Week = 52
Day = 365
 
Using time period August 1, 2023 to Oct 31, 2023, the counts should result in these results:
Quarter = 2
Month = 3
Week = 14
Day = 92
 
 
 
1 ACCEPTED SOLUTION
djallarii
Helper I
Helper I

I just figured this one out

count_field =
var __selection = SELECTEDVALUE('Date Axis Display'[Date Axis Display Order])
return
SWITCH(
    __selection,
    0, DISTINCTCOUNT(v_dim_date[calendar_year_qtr]),
    1, DISTINCTCOUNT(v_dim_date[calendar_year_mth]),
    2, DISTINCTCOUNT(v_dim_date[calendar_year_wk]),
    3, DISTINCTCOUNT(v_dim_date[calendar_date])
)

View solution in original post

1 REPLY 1
djallarii
Helper I
Helper I

I just figured this one out

count_field =
var __selection = SELECTEDVALUE('Date Axis Display'[Date Axis Display Order])
return
SWITCH(
    __selection,
    0, DISTINCTCOUNT(v_dim_date[calendar_year_qtr]),
    1, DISTINCTCOUNT(v_dim_date[calendar_year_mth]),
    2, DISTINCTCOUNT(v_dim_date[calendar_year_wk]),
    3, DISTINCTCOUNT(v_dim_date[calendar_date])
)

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.