Forum Discussion

SergioJG's avatar
SergioJG
Frequent Visitor
7 years ago
Solved

Graph positive numbers as negative

Dear colleagues, I have the next challenge; I am ploting depths. Depth (not height) is a positive value. The largest, the deeper. I can plot that vs. time on a very simple line chart. But the line ...
  • MarkLaf's avatar
    MarkLaf
    7 years ago

    I don't think you can do this with the default visuals. Besides finding a custom visual in the store, here is how to do it with R scripting:

     

    1. First, follow this article if you don't have R scripting set up for PBI yet: https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals
    2. Once set up, you should have R scripting as a visual option, click it and drag in your TIME and DEPTH columns (make sure it's TIME then DEPTH as that affects structure of what you plot with R), like so:
    3. Then, in R script editor, enter:
      plot(dataset , ylim = rev(range(dataset["DEPTH"])) ,lwd=4 , type="l" , bty="n" , col=rgb(0.2,0.4,0.6,0.8) ,xaxt = "n")
      axis(1,at = unlist(dataset["TIME"]))
      (credit to here for getting me started as I'm an R novice: https://www.r-graph-gallery.com/77-turn-y-axis-upside-down/)
    4. Hit Run script button and you're all set: