cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ccowin Frequent Visitor
Frequent Visitor

Re: Why isn't power bi referencing what I tell it to?

With Semicolons it doesnt work; I switched them all to commas and it DOES work:

Test Measure = 
CALCULATE (
    SUM ( '3301 - 3331'[BatVoltMinDay] ),
    FILTER (
        ALLEXCEPT ( '3301 - 3331', '3301 - 3331'[StationID_Name] ),
        '3301 - 3331'[BatVoltMinDay] > 0
            && '3301 - 3331'[day] = MAX ( '3301 - 3331'[day] )
    )
)
ccowin Frequent Visitor
Frequent Visitor

Re: Why isn't power bi referencing what I tell it to?

Can anyone explain why this has happened? I really still dont understand why the commas are working when the semicolons should be the correct sintax. And then when I place that into my orignal code there are still errors.

Super User
Super User

Re: Why isn't power bi referencing what I tell it to?

Hey,

 

the separator of arguments "," or ";" is derived on the settings from the OS.

 

If you copy and paste code snippets from a text to your pbix, the argument separator will not automatically converted. This conversion just happens on opening the pbix.

 

Regards,

Tom

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
ccowin Frequent Visitor
Frequent Visitor

Re: Why isn't power bi referencing what I tell it to?

Even when I type this **bleep**ing code out letter for letter it still refuses to actually associate what I'm typing with an actual table or column. I just tried restarting if as you say it resets on the start of the pbix then it should work and it doesnt. I really just feel like a complete idiot here. How does this not work?

Super User
Super User

Re: Why isn't power bi referencing what I tell it to?

Hey,

 

maybe you want to consider to share your pbix file, upload the file to onedrive or dropbox and share the link.

 

Regards,

Tom

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
Super User
Super User

Re: Why isn't power bi referencing what I tell it to?

If the variables work as individual measures does it work if you split it into 4 measures?

CurrentPrice =
CALCULATE (
    SUM ( Query1[ExchangeRate] ),
    FILTER (
        ALLEXCEPT ( Query1, Query1[Currencies] ),
        Query1[ExchangeRate] > 0
            && Query1[Date] = MAX ( Query1[Date] )
    )
)
PreviousDateWithPrice =
CALCULATE (
    MAX ( Query1[Date] ),
    FILTER (
        ALLEXCEPT ( Query1, Query1[Currencies] ),
        Query1[ExchangeRate] > 0
            && Query1[Date] < MAX ( Query1[Date] )
    )
)
PreviousPrice =
CALCULATE (
    SUM ( Query1[ExchangeRate] ),
    FILTER (
        ALLEXCEPT ( Query1, Query1[Currencies] ),
        Query1[Date] = [PreviousDateWithPrice]
    )
)
FinalMeasure = DIVIDE ( [CurrentPrice] - [PreviousPrice], [PreviousPrice], 0 )

If not, like @TomMartens suggested, could you share your .pbix?

ccowin Frequent Visitor
Frequent Visitor

Re: Why isn't power bi referencing what I tell it to?

Hey Guys,

 

Thanks for the interest over the weekend, I'll try and break it out into 3 seperate measures and see if that works and if not I'll upload the pbix for you.

ccowin Frequent Visitor
Frequent Visitor

Re: Why isn't power bi referencing what I tell it to?

While splitting the measure into 4 seperate measures it wasn't rejected for syntax but is also only giving 0 so there must be something else wrong.

 

Basically I have a list of weather stations that are all reporting their minimum daily battery voltage and I get that through an API that provides me with the last month of data points (There is also a connection to an excel file in sharepoint that our forecasters use to make the daily forecast pdf so it pulls that for future data).

 

I'd like to take the most recent and second most recent battery voltage and determine the rate of change and then graph this. This will be able to tell me which ones are dieing the quickest and I can then go to the settings and turn their reporting down as we go into winter and their solar panels begin to either get snow or just shorter days leads to less sunlight to charge.

 

Here is the link: https://www.dropbox.com/s/jwoq0kg908db1d1/PacifiCorp.pbix?dl=0

Thanks again @TomMartens  and @jdbuchanan71 

Highlighted
Super User
Super User

Re: Why isn't power bi referencing what I tell it to?

@ccowin 

When I opened your .pbix and looked at [5_BatVoltMinDay_ROC] I noticed a couple things.

There was an extra line with "Measure ="

One of the lines was compareing a name to be > 0

Once I swapped out the ; for , and fixed those the measure seems to work, wanted to check if that is what you are trying to get to.

BatteryMeasureCompare.jpg

Battery.jpg

 

The updated measure.

5_BatVoltMinDay_ROC = 

    
    VAR currentPrice =
        CALCULATE (
            SUM ( '3301 - 3331'[BatVoltMinDay] ),
            FILTER (
                ALLEXCEPT ( '3301 - 3331', '3301 - 3331'[StationID_Name] ),
                '3301 - 3331'[BatVoltMinDay] > 0
                    && '3301 - 3331'[day] = MAX ( '3301 - 3331'[day] )
            )
        )
    VAR previousDateWithPrice =
        CALCULATE (
            MAX ( '3301 - 3331'[day] ),
            FILTER (
                ALLEXCEPT ( '3301 - 3331', '3301 - 3331'[StationID_Name] ),
                '3301 - 3331'[BatVoltMinDay] > 0
                    && '3301 - 3331'[day] < MAX ( '3301 - 3331'[day] )
            )
        )
    VAR previousPrice =
        CALCULATE (
            SUM ( '3301 - 3331'[BatVoltMinDay] ),
            FILTER (
                ALLEXCEPT ( '3301 - 3331', '3301 - 3331'[StationID_Name] ),
                '3301 - 3331'[day] = previousDateWithPrice
            )
        )
    RETURN
        DIVIDE ( currentPrice - previousPrice, previousPrice, 0 )

 

 

View solution in original post

ccowin Frequent Visitor
Frequent Visitor

Re: Why isn't power bi referencing what I tell it to?

Thats it!

 

I must have copy/pasted the measure from someone's snippet into there and it must have been messing everything up.

 

Thanks so much for your guys help; I wouldn't have been able to get by myself!

Helpful resources

Announcements
Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 202 members 2,479 guests
Please welcome our newest community members: