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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
kyrpav
Helper V
Helper V

Find first non blank after ordering a filtered table

I have a table that has one column with hex color code for conditional formating. So in table i want to use a measure that for a filtered part of the table (by a matrix) i can get the firstnonblank record.

 

codedateconditional_formatinggeneric_ordervalues
12020/06/01 40015

1

2020/06/01#eb331840025

1

2020/06/01#dddddd40035

1

2020/07/01#dddddd400110
12020/07/01 400210
12020/07/07#eb3318400310

 

Data are like this so my matrics i am selecting on

  • row header: code ,
  • in column i have: dates
  • and in data i have: values

So based on the generic order i want to select the first not null value for each month for each code.

 

How can i do it cause classic call of firstnonblank(field,1) is not working

5 REPLIES 5
v-xicai
Community Support
Community Support

Hi @kyrpav ,

 

You may create measure like DAX below.

 

Measure1 =
CALCULATE (
    FIRSTNONBLANK ( 'Table1'[Payment Method], 1 ),
    FILTER (
        ALLSELECTED ( 'Table1' ),
        'Table1'[code] = MAX ( 'Table1'[code] )
            && YEAR ( 'Table1'[Date] ) = YEAR ( MAX ( 'Table1'[Date] ) )
            && MONTH ( 'Table1'[Date] ) = MONTH ( MAX ( 'Table1'[Date] ) )
    )
)

 

If I misunderstood it, could you please share your sample data and desired output screenshots for further analysis? You can also upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Please read this post to get your answer quickly: How to Get Your Question Answered Quickly.

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

Let me give you some more example

 

codedateconditional_formatinggeneric_ordervalues
12020-06-01 40015
12020-06-01#eb331840025
12020-06-01#dddddd40035
12020-07-01#dddddd400110
12020-07-01 400210
12020-07-01#eb3318400310
22020-06-01 50017
22020-06-01 50027
22020-06-01#dddddd50037
22020-07-01#eb331850011
22020-07-01 50021
22020-07-01 50031

 

 
 
 
 

So for code 1, generic order of 4002 have to be seleced with red color #eb3318 for june while for july #dddddd .

For code 3 for june i have to get color for generic order 5003 and for july color for generic order 5001.

 

 

 

 

v-xicai
Community Support
Community Support

Hi @kyrpav ,

 

You may create measure like DAX below.

 

conditional_formating_New =
VAR _lastnoblankorder =
    CALCULATE (
        MAX ( Table1[generic_order] ),
        FILTER (
            ALL ( Table1 ),
            Table1[code] = MAX ( Table1[code] )
                && Table1[date] = MAX ( Table1[date] )
                && Table1[generic_order] <= MAX ( Table1[generic_order] )
                && Table1[conditional_formating] <> BLANK ()
        )
    )
RETURN
    CALCULATE (
        MAX ( Table1[conditional_formating] ),
        FILTER (
            ALLEXCEPT ( Table1, Table1[code], Table1[date] ),
            Table1[generic_order] = _lastnoblankorder
        )
    )

179.png

 

 

 

 

 

 

 

 

 

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

@kyrpav , Create a measure like this and return the hexcode in place of color

color =
switch ( true(),
FIRSTNONBLANK(Table[commodity],"NA") ="commodity1" && sum(Table[Value]) >500,"lightgreen",
FIRSTNONBLANK(Table[commodity],"NA") ="commodity2" && sum(Table[Value]) >1000,"lightgreen",
/// Add more conditions
"red"
)

 

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

what is comodity why sum is needed ....? i do not want to know any value i want ot select this conditional formating measure in conditional formating of values for background color

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors