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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.