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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gerplus
New Member

LastNonBlank value & target value on gauge

Sorry for maybe such a basic problem of mine, I'm currently in the learning curve but can't figure out DAX measure so simply yet.

 

I'v got data sample as following:

 

Screenshot 2020-02-17 at 09.57.49.png

 

Would like to vizualize two gauges, actual vs. target values:

- latest non blank 'BOMValue' vs. respective 'BOMTargetValue' (for 'Detector' device only)

- same for 'Bridge' device only

 

In my mind, it shoud be solved by DAX codes, right? Something like:

Latest Detector BOM = VAR CurrentBOMValue = LASTNONBLANK ('UnitTable'[BOMValue], 0)
RETURN CALCULATE (LASTNONBLANK(UnitTable[BOMValue], 0))

 

Thanks for a million

1 ACCEPTED SOLUTION

sorry, tested on data that were to simplified, so it gave the correct answer for the wrong reason.

Can you try this code instead:

Last BOM Value =
CALCULATE (
    SUM ( Data[BOM Value] ),
    LASTNONBLANK ( 'Data'[Date], CALCULATE ( SUM ( Data[BOM Value] ) ) )
)

Idealy, 'Data'[Date] should reference a date/calendar table, so if you have one of those, replace this part of the code. 

View solution in original post

5 REPLIES 5
sturlaws
Resident Rockstar
Resident Rockstar

Hi @gerplus 

 

writing your measures like this is sufficient:

Last BOM Value = LASTNONBLANK('Table'[Bom value];0)

 

and then add the field Detector/Bridge to the visual filter pane of each gauge, and set it to filter to equal to detector and bridge, respectively

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too. 

@sturlaws 

thank you for help, now I understand the idea how to solve it, but this formula gives me errors and I don't know why:

The syntax for ';' is incorrect. (DAX(LASTNONBLANK(UnitTable[BOMValue];0)))

@sturlaws 

Never mind, I figured out the formula problem, it should have "," instead of ";"

 

Now I see values on gauge but the next problem is that formula is not giving value of last non blank (last date) but maximum value from column instead

sorry, tested on data that were to simplified, so it gave the correct answer for the wrong reason.

Can you try this code instead:

Last BOM Value =
CALCULATE (
    SUM ( Data[BOM Value] ),
    LASTNONBLANK ( 'Data'[Date], CALCULATE ( SUM ( Data[BOM Value] ) ) )
)

Idealy, 'Data'[Date] should reference a date/calendar table, so if you have one of those, replace this part of the code. 

@sturlaws 

Thank you so much, you helped me to understand the logic how I should think in PBI!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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