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
jac88
Helper II
Helper II

How add Weekend for the Custom Title?

Hello, 

 

I have created a custom title by combining "Primary Category" data. I need to add "WeekEnd" when it is Saturday or Sunday. I tried this using creating two columns below, but it did not work. Somehow it will show the wrong category combined and "WeekEnd only shows one person.

Column = VAR NewLine =
"
/
"
RETURN
CONCATENATEX(VALUES(df_ProServUtilizationTracker[Primary Categories]), df_ProServUtilizationTracker[Primary Categories], NewLine)
Title test = IF(ProDetail_CrossJoin_test[WeekName] = "Saturday" || ProDetail_CrossJoin_test[WeekName] = "Sunday", "WeekEnd", ProDetail_CrossJoin_test[Column])

Is there a way I can join "WeekEnd" to the title based on Saturday and Sunday? 

jac88_0-1651090533497.png

 

This may be a little confusing, please see the attached file. 

https://drive.google.com/file/d/1TR96CWb-itIS7SqU7ByrhrI1FQL6of3m/view?usp=sharing 

 

Thank you so much 

17 REPLIES 17
MFelix
Super User
Super User

Hi @jac88 ,

 

Try the following code:

 

Titles =
VAR NewLine = " / "
VAR Categoryvalue =
    CONCATENATEX (
        VALUES ( df_ProServUtilizationTracker[Primary Categories] ),
        df_ProServUtilizationTracker[Primary Categories],
        NewLine
    )
VAR Weekendtext =
    IF ( MAX ( 'VAR vCalendar'[WeekName] ) IN { "Saturday", "Sunday" }, "Weekend" )
RETURN
    Categoryvalue
        & IF ( Weekendtext <> BLANK () && Categoryvalue <> BLANK (), NewLine ) & Weekendtext

MFelix_0-1651269909838.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix 

 

Hello, 


Thank you so much for your response, this is kinda working. I want to show the Weekend regardless of the blank. If there is an event or not it should show up.  So I remove the blank part of your formula did not work.

jac88_0-1651608252544.png

 

https://drive.google.com/file/d/1tM6gCCZlvoZou2fCs-l8jwG9SDQkRLuF/view?usp=sharing 

 

Thank you so much for your time and help. 

I was looking at your model and since you have the bi directional filter it's not giving correct result I will check and get back to you


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @jac88,

 

Did you tried my formula?

 

The blank part that I use is only to avoid having the / on the measure if you don't have events.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

 

I have to change the filter direction and made a small change to your formula. So what I am trying to do is based on CalType, weekend days are different. For instance, "iMetaCal" weekends are Friday and Saturday. Rest is a normal weekend (Saturday and Sunday). 

 

Somehow my one is not working the way I want. I

Titles = 
VAR NewLine = " / "
VAR Categoryvalue =
    CONCATENATEX (
        VALUES ( df_ProServUtilizationTracker[Primary Categories] ),
        df_ProServUtilizationTracker[Primary Categories],
        NewLine
    )
VAR Weekendtext =
    IF(MAX(df_ProServUtilizationTracker[sp_Employees.CalType]) = "iMetaCal" ||  MAX ( 'VAR vCalendar'[WeekName] ) IN { "Saturday", "Friday" }, "iMETAWeekend", 
        IF(MAX(df_ProServUtilizationTracker[sp_Employees.CalType]) = "Standard" ||  MAX ( 'VAR vCalendar'[WeekName] ) IN { "Saturday", "Sunday" }, "Weekend"))
RETURN
    Categoryvalue
        & IF ( Weekendtext <> BLANK () && Categoryvalue <> BLANK (), NewLine ) & Weekendtext

 

If you have a few more minutes, can you please take look at why my changes are wrong? I truly appreciate your help and time.  I am so close. 

 

https://drive.google.com/file/d/1tM6gCCZlvoZou2fCs-l8jwG9SDQkRLuF/view

 

Thank you 

Hi @jac88 ,

 

You need to use an AND statement on your weekend part and also add a next level of IF to mark all the weekened values try the following:

 

Titles =
VAR NewLine = " / "
VAR Categoryvalue =
    CONCATENATEX (
        VALUES ( df_ProServUtilizationTracker[Primary Categories] ),
        df_ProServUtilizationTracker[Primary Categories],
        NewLine
    )
VAR Weekendtext =
    IF (
        MAX ( df_ProServUtilizationTracker[sp_Employees.CalType] ) = "iMetaCal"
            && MAX ( 'VAR vCalendar'[WeekName] ) IN { "Saturday", "Friday" },
        "iMETAWeekend",
        IF (
            MAX ( df_ProServUtilizationTracker[sp_Employees.CalType] ) = "Standard"
                && MAX ( 'VAR vCalendar'[WeekName] ) IN { "Saturday", "Sunday" },
            "Weekend"
        )
    )
RETURN
    IF (
        MAX ( 'VAR vCalendar'[WeekName] )
            IN { "Saturday", "Friday" }
                && Categoryvalue
                    & IF ( Weekendtext <> BLANK () && Categoryvalue <> BLANK (), NewLine ) & Weekendtext
                    = BLANK (),
        "Weekend",
        Categoryvalue
            & IF ( Weekendtext <> BLANK () && Categoryvalue <> BLANK (), NewLine ) & Weekendtext
    )

 

MFelix_0-1651759086027.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hello @MFelix 

 

Sorry to be a pest, and thank you so much for the quick response. This is almost perfect, but there is a small issue. For instance, "iMetaWeekend" is Friday showing all the way for all employees. I only need to show employees with the Calendar type "iMetaCal".


Do you know by any chance, how to do it by the employee? One last thing, Sunday is not showing as a weekend. Try to find out why is that, but no luck so far. 


Again, thank you so much

 

Once again sorry but travelling back home will get an answer tomorrow ASAP. 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @jac88,

 

Tomorrow I will give it a look I'm without computer now, but I will pick this up ASAP. 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix ,

 

Thank you so much for your hlep. I just wanted to know why my changes to your formula are not working. It's showing every day now. 

 

Again, thank you

Hi @jac88 ,

 

The issues are related with context that is giving an incorrect result because of the many to many relationship you have, so in this case the Calendar type is not being pickedup correctly by the employe type but by the manager type.

 

In this case I have made the following chages to your code:

Titles =
VAR calendarType =
    CALCULATE (
        SELECTEDVALUE ( df_ProServUtilizationTracker[sp_Employees.CalType] ),
        ALLSELECTED ( df_ProServUtilizationTracker[sp_Employees.Name] )
    )
VAR NewLine = " / "
VAR Categoryvalue =
    CONCATENATEX (
        VALUES ( df_ProServUtilizationTracker[Primary Categories] ),
        df_ProServUtilizationTracker[Primary Categories],
        NewLine
    )
VAR Weekendtext =
    IF (
        calendarType = "iMetaCal"
            && MAX ( 'VAR vCalendar'[WeekName] ) IN { "Saturday", "Friday" },
        "iMETAWeekend",
        IF (
            calendarType = "Standard"
                && MAX ( 'VAR vCalendar'[WeekName] ) IN { "Saturday", "Sunday" },
            "Weekend"
        )
    )
RETURN
    Categoryvalue
        & IF ( Weekendtext <> BLANK () && Categoryvalue <> BLANK (), NewLine ) & Weekendtext

 

Has you can see the change on the code is the fact that instead of using the MAX directly to get the CalType i'm making a Calculation of the CalType but restricted by the enmploye name (ALLSELECTED part) this allows to get for that specific person the calendar type. 

 

MFelix_0-1651837602961.png

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

 

Thank you so much for the resolution. I hope you had a great weekend as well. This is good but the only issue is "iMetaWeekend" Friday and Saturday only work for April. Do you happen to know why is that? 

 

Thank you so much 

Hi @jac88 ,

 

I'm looking into this.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix 

Thank you so much, last few days I was trying to figure out messing the Dax, and adding stuff to all select sections. Still not luck. 

For the caltype = iMeta Saturday is missing. Also, not all people show weekend lable. 

 

Again, thank you so much for your time and help. 

Hi @jac88 ,

 

Your issue is that the data for those specific dates are not in your model: so you are getting null values so the weekend information is not going trough. This is also happening in other valueseven when the calendar is no imeta.

 

I need to try some different approach, please have some patience.

 

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hello @MFelix ,

 

Thank you so much. I was stuck and I could not find it. Please let me know if you found a workaround. Again, thank you so much for your time. 

Hello @MFelix,

 

Thank you so much for taking look at this. Yes, I used the same formular. I can check the filter. 

jac88_0-1651682188060.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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