cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Re: Trying to make a row-based measure

Thanks for the help! I'm having some issues with getting the measures to work in SSAS, but I think that's for me to figure out 🙂

 

Would you be able to help me out in writing these cumulative cost/age measures? Not sure if they're hard to write. 

 

 

cumulative.PNG

 

Highlighted
Community Support
Community Support

Re: Trying to make a row-based measure

Hi, @arjuncheema 

 

You may try the following measure in SSAS.

Cumulative Age = 
var _date = SELECTEDVALUE(Table1[Date])
var _equipmentid = SELECTEDVALUE(Table1[Equipment ID])
var _eventid = SELECTEDVALUE(Table1[Event ID])
var _maxdate = 
CALCULATE(
            MAX(Table1[Date]),
            FILTER(
                ALL(Table1),
                Table1[Equipment ID] = _equipmentid
            )
        )
return
IF(
    _eventid = "ENGINE EXCHANGE",
    0,
    IF(
        _date = _maxdate
        ,
        SELECTEDVALUE(Table1[Hour Reading])-
        CALCULATE(
            SUM(Table1[Hour Reading]),
            FILTER(
                ALL(Table1),
                Table1[Equipment ID] = _equipmentid&&
                Table1[Event ID] = "ENGINE EXCHANGE"
            )
        ),
        SELECTEDVALUE(Table1[Hour Reading])
    )
)
Cumulative Cost = 
var _date = SELECTEDVALUE(Table1[Date])
var _equipmentid = SELECTEDVALUE(Table1[Equipment ID])
var _eventid = SELECTEDVALUE(Table1[Event ID])
var _lastdate = 
CALCULATE(
    MAX(Table1[Date]),
    FILTER(
        ALL(Table1),
        Table1[Equipment ID] = _equipmentid&&
        Table1[Event ID] = "ENGINE EXCHANGE"&&
        Table1[Date]<_date
    )
)
return
IF(
    _eventid = "ENGINE EXCHANGE",
    SELECTEDVALUE(Table1[Cost]),
    CALCULATE(
        SUM(Table1[Cost]),
        FILTER(
            ALL(Table1),
            Table1[Equipment ID] = _equipmentid&&
            Table1[Date]>=_lastdate&&
            Table1[Date]<=_date
        )
    )
)

 

Result:

c1.png

 

Best Regards

Allan

 

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

View solution in original post

Highlighted
Regular Visitor

Re: Trying to make a row-based measure

@v-alq-msft 
Great, thanks! With the other measures you had helped me out with, would they vary in SSAS? e.g. Is Engine, Engine Life, Current Engine, etc.

Highlighted
Community Support
Community Support

Re: Trying to make a row-based measure

Hi, @arjuncheema 

 

I have tried to use SSAS with live connection. It appears normal.

a1.png

 

Best Regards

Allan

 

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

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors