Forum Discussion

CBAEZA's avatar
CBAEZA
Regular Visitor
1 year ago

Dynamic Column Name depending on Slicer

Good day,

 

I've been working with a Visual that shows Vol with the option of choosing from two separate slicers the periods of time you want to compare.

One takes info from a basic Date table in this format (spans from JAN22 to NOV24):

DATEYEARMONTHMONTH NAME#MONTH#DAY#WEEKWEEKWEEKEND?WEEKDAYQUARTERMW#SEMESTERSortMonthYearM-YSortTrimYearT-YSortSemYearMES ESPAÑOLMES AÑOINDEX
01/10/20242024OCTOCTOBER101240FalseTUESDAY42S2202410OCT-24202404T4-24202402OCT 2024OCT 202457

The second one comes from a summarized version of the first:

MONTHMES ESPAÑOLYEARINDEX
JULJUL 2022202230
AUGAGO 2022202231

The current month is calculated with VOL= SUM('Query O2C'[VOL]) filtered by the first slicer, the previous year with VOL AA = CALCULATE(Measures[VOL], DATEADD(dDate[Date], -12, MONTH)) and VOL M2 with: 

VOL M2 =
VAR IND = SELECTEDVALUE('MONTH 2'[MONTH])
VAR CY = SELECTEDVALUE('MONTH 2'[YEAR])
RETURN
SWITCH(
    IND,
        "ENE", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 1, YEAR(dDate[DATE])= CY),
        "FEB", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 2, YEAR(dDate[DATE]) = CY),
        "MAR", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 3, YEAR(dDate[DATE]) = CY),
        "ABR", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 4, YEAR(dDate[DATE]) = CY),
        "MAY", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 5, YEAR(dDate[DATE]) = CY),
        "JUN", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 6, YEAR(dDate[DATE]) = CY),
        "JUL", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 7, YEAR(dDate[DATE]) = CY),
        "AGO", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 8, YEAR(dDate[DATE]) = CY),
        "SEP", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 9, YEAR(dDate[DATE]) = CY),
        "OCT", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 10, YEAR(dDate[DATE]) = CY),
        "NOV", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 11, YEAR(dDate[DATE]) = CY),
        "DIC", CALCULATE(Measures[VOL],MONTH(dDate[DATE]) = 12, YEAR(dDate[DATE]) = CY)
)
For additional clarity I'd like for the title of the columns in the matrix table to dynamically change depending on the chosen month in both slicers. 

From this:

Slicer 1 linked to dDate[MES ESPAÑOL]: JUN 2024

Slicer 2 linked to MONTH 2[MES ESPAÑOL]: MAY 2022

Visualization:

 VOL AAVOL M2VOL CMDIF VOL AADIF VOL M2
Retail41400004244000423600091000-8000
Wholesale11300001231000115400016000-77000


To this:

 VOL JUN 2023VOL MAY 2022VOL JUNE 2024DIF VOL AADIF VOL M2
Retail4144000424400042360009100)-8000
Wholesale11380001231000115400016000-77000

 

I've tried using these two in Dynamic fields to pull the name: 

  • SELECTEDVALUE
  • IF(ISFILTERED('MONTH 2'[Mes ESPAÑOL]), CONCATENATE("VOL ", (IF(HASONEVALUE('MONTH 2'[Mes ESPAÑOL]),FIRSTNONBLANK('MONTH 2'[Mes ESPAÑOL],"") ,""))), "SELECT A MONTH")

However it has come to my attention that Parameters are incapable of considering the filters despite working perfectly fine as an independent measure. Is there a way to work around this?  

 

Appreciate the help.

4 Replies