Forum Discussion

berna's avatar
berna
Regular Visitor
3 years ago

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

Related to https://community.powerbi.com/t5/Desktop/Display-difference-between-bars-in-Line-and-Column-Clustered/m-p/451898#M209261

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
 

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