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

CONDITIONAL FORMATTING FOR YEARS WITH DIFFERENT TARGETS

Hi all, 

 

I have a simple measure of costs which have different targets for 2022, 2023 and 2024. 

I need that my table replies to conditional formatting considering that, once a specific year is flagged in the filter, the colors will consider the targets of that year. 

 

What's the calculation for that, please?

 

Thank you.

1 ACCEPTED SOLUTION

Hi @v-yilong-msft

 

I found a solution, posting here what worked out:

 

Epoloni12_2-1711631780154.png

 

Thank you for your support. 

View solution in original post

7 REPLIES 7
v-yilong-msft
Community Support
Community Support

Hi @Epoloni12 ,

I create a simpe table and a new measure.

vyilongmsft_0-1711074578331.png

MEASURE =
VAR _A =
    MAX ( 'Table'[Year] )
RETURN
    SWITCH ( _A, 2022, 100, 2023, 200, 2024, 150, BLANK () )

vyilongmsft_1-1711074694429.png

Then I create a measure named Color and go to the Conditional formatting.

Color =
IF (
    'Table'[Measure] = 200,
    "Green",
    IF ( 'Table'[Measure] = 100, "Red", "Blue" )
)

vyilongmsft_2-1711074856509.pngvyilongmsft_3-1711074893520.png

vyilongmsft_4-1711074975855.png

Finally you will get what you want.

vyilongmsft_5-1711075127430.png

vyilongmsft_6-1711075171863.png

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yilong-msft ,

 

Thank you for the detailed information. 

I have a calendar table and one target file per year (total of 3 excel files) following this standard : 

PeriodCostComplaintsProductivityInspection
Jan/202XXXXYYYY UUU%ZZZ%

 

Then i tried to apply the first formula with the values of my targets, but didn't work, do you know what could be the problem, please?

 

Epoloni12_1-1711096423847.png

 

Thank you.

 

 

Hi @Epoloni12 ,

First of all, there should be a space after the VAR, _A indicates a variable, you can try correcting it this way and see if you can correct the error.

If that still doesn't work, can you provide me with more information or a .pbix file so I can do more in-depth research?

How to Get Your Question Answered Quickly 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yilong-msft 

 

I added the space, but still not working. 

I added here the files which are the basis for my calculation. Further info is ommited and i highlighted in yellow the reffered columns:

 

https://drive.google.com/drive/folders/1ia5YC9ht0aG_6NluwGEtJfFafAURVH3X

 

Thank you very much.

 

 

 

Hi @Epoloni12 ,

I can not open your .pbix file, can you change a way to upload your .pbix file? If you upload the .pbix file, I will do a deeper research.

 

 

Best Regards

Yilong Zhou

Hi @v-yilong-msft

 

I found a solution, posting here what worked out:

 

Epoloni12_2-1711631780154.png

 

Thank you for your support. 

_AAndrade
Super User
Super User

Hi,

Can you provide a picture of the output what of you're looking for?





Did I answer your question? Mark my post as a solution! Kudos are welcome.

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.