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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Marshmallow
Helper II
Helper II

Dynamic title on date hierarcy

Hi 

I am trying to get dynamic title based on the date selected (which is a date hierarcy). On the Date hierarchy i selected: Year and Month. 

Marshmallow_0-1751609432556.png

 

Then I proceed with my formula is:

Dynamic_title_Appl_received = "New Applications Received in:" & " " &
    Var MaxValue=3
    Var vcountSubCategory=DISTINCTCOUNT('Calendar'[Month Year])
    Var EndName=
    IF(
        vcountSubCategory > MaxValue," " &"and"&" "&(vcountSubCategory-MaxValue)&" "&"other periods")
    Return
    If(
        ISFILTERED('Calendar'[Month Year]),
    CONCATENATEX(
        TOPN(MaxValue, VALUES('Calendar'[Month Year])),
        ('Calendar'[Month Year]),
        ", "
        )&EndName,
        "All Periods")
 
 
Unfortunately it doesn't work..it jus says All Periods whenever I selected a period.
 
Can someone please help?
1 ACCEPTED SOLUTION

Hi @Marshmallow, try with this logic

test1 =
VAR selectedmonthyear = values ('Calendar'[Month Year])
VAR MaxToShow = 3
VAR TotalSelected = COUNTROWS(selectedmonthyear)
VAR PeriodsToShow = TOPN(MaxToShow, selectedmonthyear, 'Calendar'[Month Year], ASC)
VAR MorePeriods = IF(TotalSelected > MaxToShow, " and " & (TotalSelected - MaxToShow) & " more", "")
VAR Result = 
"New Applications Received in: " & 
IF(TotalSelected = COUNTROWS(ALL('Calendar'[Month Year])),
"All",
CONCATENATEX(PeriodsToShow, 'Calendar'[Month Year], ", ") & MorePeriods
)
RETURN
Result

 

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

View solution in original post

3 REPLIES 3
ajaybabuinturi
Memorable Member
Memorable Member

Hi @Marshmallow,
Instead using Date hierarchy in the slicer, use Date [Month Year] field to get the dynamic title by Month Year.

Try with this

Dynamic_title_Appl_received = "New Applications Received in: " & 
VAR MaxValue = 3
VAR vcountSubCategory = DISTINCTCOUNT('Calendar'[Month Year])
VAR EndName = IF(vcountSubCategory > MaxValue, 
                " and " & (vcountSubCategory - MaxValue) & " other periods",
                "")
VAR Result = 
IF(ISFILTERED('Calendar'[Month Year]),
CONCATENATEX(TOPN(MaxValue, VALUES('Calendar'[Month Year])),'Calendar'[Month Year],", ") & EndName, "All Periods")

RETURN
Result

 

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

Hi, it didn't work. However I have since come up with a solution however I need to limit the output to only shows 3 periods. are you able to assist? This is my new code:

 

test1 =
VAR selectedmonthyear =
    values ('Calendar'[Month Year])
    return
    "New Applications Received in: "
    & if(
        COUNTROWS(selectedmonthyear) = COUNTROWS(all('Calendar'[Month Year])), "All",
        CONCATENATEX(VALUES('Calendar'[Month Year]), 'Calendar'[Month Year], ","))

Hi @Marshmallow, try with this logic

test1 =
VAR selectedmonthyear = values ('Calendar'[Month Year])
VAR MaxToShow = 3
VAR TotalSelected = COUNTROWS(selectedmonthyear)
VAR PeriodsToShow = TOPN(MaxToShow, selectedmonthyear, 'Calendar'[Month Year], ASC)
VAR MorePeriods = IF(TotalSelected > MaxToShow, " and " & (TotalSelected - MaxToShow) & " more", "")
VAR Result = 
"New Applications Received in: " & 
IF(TotalSelected = COUNTROWS(ALL('Calendar'[Month Year])),
"All",
CONCATENATEX(PeriodsToShow, 'Calendar'[Month Year], ", ") & MorePeriods
)
RETURN
Result

 

Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.