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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
berna
Regular Visitor

How to remove last data point on visual? Difference between bar charts.

berna_0-1666976270434.png

Related to https://community.powerbi.com/t5/Desktop/Display-difference-between-bars-in-Line-and-Column-Clustere...

What I'm interested in plotting is the difference in hours between the blue columns which are shown in the line chart. I've tried two solutions but both don't seem to work. It says the x axis parameters can't be filtered or used in an if statement bc it's mixing text with numerals I think. Below is what I've tried. 

 

Measure =
var minimumDay = CALCULATE(MIN('Table1'[# S]), all('Table1'))
VAR lastHrs =
    CALCULATE ( MAX ( 'Table1'[# S] ),
        FILTER ( ALL ( 'Table1' ), 'Table1'[# S] < MIN ( 'Table1'[# S] ) )
    )
VAR lastTotal =
    CALCULATE (
        SUM ( 'Table1'[Equip Hours] ),
        FILTER ( ALL ( 'Table1' ), Table1[# S] = lastHrs )
    )
*not sure if this would work even if x axis wasn't text returnif(min('Table1'[Date])= minimumDay, 0, lastTotal - MIN(Table1[Equip Hours]))
*above chart is  return lastTotal - MIN(Table1[Equip Hours])
I can't figure out a way to do this return lastTotal - MIN(Table1[Equip Hours]while filtering out the last data point. Below is my data source. 
Table1
DateTrailer-HeadEquip HoursServices Performed# S# F# O# BUPT SUPT F
8/31/202278-2727Oil Sample Collected78-2.478-2.278-2.178-2.242
9/7/202278-2723Filter Changed,Breather Changed78-2.478-2.178-2.178-2.141
9/15/202278-2793Oil Sample Collected78-2.378-2.178-2.178-2.131
9/29/202278-2968Oil Sample Collected78-2.278-2.178-2.178-2.121
10/1/202278-21013Oil Sample Collected78-2.178-2.178-2.178-2.111
10/2/202278-21015Oil Sample Collected,Oil Changed,Filter Changed,Breather Changed78-278-278-278-200
Table 1.1
UPT OUPT Bsample.1filters.1oil.1breather.1
1278-2   
11 78-2 78-2
1178-2   
1178-2   
1178-2   
0078-278-278-278-2
 
berna_1-1666977038739.png

Another issue I haven't been able to solve is choosing the correct equip hours if there are two unique identifiers. For example, 78.2.4. Right now I have to either choose MIN, MAX, AVG which can lead to incorrect calcaulations. I would need to check the sample.1 column to see if blank or not. 

 

Results

Feedback Type:
Frown (Error)

Timestamp:
2022-10-31T17:03:00.8174500Z

Local Time:
2022-10-31T12:03:00.8174500-05:00

Session ID:
f50486aa-726b-424e-aff6-800c51e600b9

Release:
September 2022

Product Version:
2.109.642.0 (22.09) (x64)

Error Message:
MdxScript(Model) (16, 11) Calculation error in measure 'Table1'[Measure]: DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

OS Version:

4 REPLIES 4
lbendlin
Super User
Super User

You should not use a line chart visual if your data points do not have a temporal succession.

Right, it's going to be a bar chart on it's own. 

Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Updated. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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