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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
user_34
Frequent Visitor

Creating a table which has dynamic header and data

Hi all 
I am creating a new table in which I am creating a date picker using this DAX
Calendar =
VAR Days = CALENDAR ( DATE ( 2024, 1, 1 ), DATE ( 2024, 12, 31 ) )
RETURN ADDCOLUMNS (
Days,
"Formatted Date", FORMAT([Date], "yyyy-mm-dd"),
"Year", YEAR ( [Date] ),
"Month Number", MONTH ( [Date] ),
"Month", FORMAT ( [Date], "mmmm" ),
"Year Month Number", YEAR ( [Date] ) * 12 + MONTH ( [Date] ) - 1,
"Year Month", FORMAT ( [Date], "mmm yy" ),
"Week Number", WEEKNUM ( [Date] ),
"Week Number and Year", "W" & WEEKNUM ( [Date] ) & " " & YEAR ( [Date] ),
"WeekYearNumber", YEAR ( [Date] ) & 100 + WEEKNUM ( [Date] ),
"Is Working Day", NOT WEEKDAY([Date]) IN {1,7}
)
Now I have data 

CategoryFileStart TimeTarget TimeReceived TimeFinal timeDate
As32983:00 AM8:00 AM3:00 AMMet08-04-2024
As32993:00 AM8:00 AM4:00 AMMet07-04-2024
As33003:00 AM8:00 AM5:00 AMMet06-04-2024
As33013:00 AM8:00 AM6:00 AMMet08-04-2024
As33023:00 AM8:00 AM7:00 AMMet07-04-2024
As33033:00 AM8:00 AM8:00 AMMet06-04-2024
As33043:00 AM8:00 AM9:00 AMNot Met08-04-2024
Bs33054:00 AM8:00 AM10:00 AMNot Met07-04-2024
Bs33065:00 AM8:00 AM11:00 AMNot Met06-04-2024
Bs33076:00 AM8:00 AM12:00 PMNot Met08-04-2024
Bs33087:00 AM8:00 AM1:00 PMNot Met07-04-2024
Bs33098:00 AM8:00 AM2:00 PMNot Met06-04-2024
Bs33109:00 AM9:00 AM  08-04-2024


Now I want create a table in which category name and today date,yesterday date and day before yesterday date as a header  in which target should show as values where I want to apply conditional formatting like

1. for 8 April for the category a if their final time is between target time and start time it should show green 

2. if final time =null but system time > Target time  show red
3. if final time =null but system time < Target time  show yellow
Attaching the excel file 
https://docs.google.com/spreadsheets/d/1DQd8Xj1mJzYnZeTWXmgNRJIOwCLaz10lBBKsDQK91q4/edit?usp=sharing

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @user_34 ,

Thanks for the reply from @amitchandak , please allow me to provide another insight: 

 

Here are the steps you can follow:

1. Create measure.

color =
var _today=TODAY()
return
SWITCH(
    TRUE(),
    MAX('Table'[Date])=_today&&MAX('Table'[Final time])>=MAX('Table'[Start Time])&&MAX('Table'[Final time])<=MAX('Table'[Target Time]),"green",
    MAX('Table'[Date])=_today&&MAX('Table'[Final time])=BLANK()&&MAX('Table'[Start Time])>MAX('Table'[Target Time]),"red",
    MAX('Table'[Date])=_today&&MAX('Table'[Final time])=BLANK()&&MAX('Table'[Start Time])<MAX('Table'[Target Time]),"yellow")

2. Select filed – Conditional formatting – Background color.

vyangliumsft_0-1712654043711.png

 

vyangliumsft_1-1712654043713.png

3. Result:

vyangliumsft_2-1712654099193.png

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @user_34 ,

Thanks for the reply from @amitchandak , please allow me to provide another insight: 

 

Here are the steps you can follow:

1. Create measure.

color =
var _today=TODAY()
return
SWITCH(
    TRUE(),
    MAX('Table'[Date])=_today&&MAX('Table'[Final time])>=MAX('Table'[Start Time])&&MAX('Table'[Final time])<=MAX('Table'[Target Time]),"green",
    MAX('Table'[Date])=_today&&MAX('Table'[Final time])=BLANK()&&MAX('Table'[Start Time])>MAX('Table'[Target Time]),"red",
    MAX('Table'[Date])=_today&&MAX('Table'[Final time])=BLANK()&&MAX('Table'[Start Time])<MAX('Table'[Target Time]),"yellow")

2. Select filed – Conditional formatting – Background color.

vyangliumsft_0-1712654043711.png

 

vyangliumsft_1-1712654043713.png

3. Result:

vyangliumsft_2-1712654099193.png

 

Best Regards,

Liu Yang

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

amitchandak
Super User
Super User

@user_34 , You can create a measure and use that in conditional formatting using field value option

 

example measures

 

 

Color = Switch( True() ,
Max(Table[Status]) < 200 ,
Switch(true(),
[ERB] = .25 , "Orange" ,
"Red "
) ,
Max(Table[Status]) < 500 ,
Switch(true(),
[ERB] = .25 , "Orange" ,
"Red "
) ,
Switch(true(),
[ERB] = .25 , "Orange" ,
"Red "
)
)

Color Date =
var _min =minx(allselected(Date,Date[Year])
return
Switch( true(),
FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"lightgreen",
FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"blue",
"red")

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...
https://amitchandak.medium.com/power-bi-where-is-the-conditional-formatting-option-in-new-format-pan...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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