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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arpost
Advocate V
Advocate V

Is it possible to set dates used in a visual to min of a date?

I have a unique scenario and am hoping someone can help me with it. I am wanting to track values of data over time but annotate when certain percentages changed with what would be the equivalent of a dynamic "constant" line. Here's a mock verson of the data:

Values

DateCategoryValue
1/1/2014New$10,000
1/2/2014Returning$25,000

 

Change Event

DatePercentage
1/1/201364.5%
6/1/201465.5%

I've "hacked" this in my report by using a Line and clustered column chart with the Values set to the Line portion and the percentage change events as Column values, which currently appear as follows:

arpost_0-1626444717396.png

This works well enough, but I am hitting a roadblock when the Date of the change event pre-dates the start of the data; in this example, the data may start in 2014, but the change event from 2013 is still showing:

arpost_1-1626444850757.png

Anyone have some clever thoughts on how I might go about making it so this visual only shows data that starts when the line values start?

1 ACCEPTED SOLUTION

OK, then maybe something like this:

 

_yourPercentageMeasure = 
VAR __maxDate =
CALCULATE(
    MAX(changeEvent[Date]),
    ALL(changeEvent)
)
RETURN
CALCULATE(
    MAX(changeEvent[Percentage]),
    FILTER(
        changeEvent,
        changeEvent[Date] = __maxDate
    )
)

 

 

I'm assuming here that your changeEvent table is related to your calendar table from which the shared date axis comes.

 

I seem to get the required output (I had to change the dates to fit with my calendar)

BA_Pete_0-1626450365381.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

6 REPLIES 6
BA_Pete
Super User
Super User

Hi @arpost ,

 

I'm probably oversimplifying this, but have you tried something like this?

_yourPercentageMeasure =
IF(
  ISBLANK([yourLineValueMeasure]),
  BLANK(),
  [yourPercentageValueMeasure]
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




@BA_Pete, thanks for posting. I just tried your suggestion but couldn't get it to work. These values are all just base fields, so no measures. When I attempted to convert to using measures with the ISBLANK logic, all change event columns disappeared because there was no overlap between the date of the % change and the date of values entered. I've got the visual configured as such:

arpost_0-1626447078889.png

 

Ok, so I guess more like this:

_yourPercentageMeasure =
IF(
  ISBLANK( SUM(yourTable[Value 1]) + SUM(yourTable[Value 2]) ),
  BLANK(),
  SELECTEDVALUE(yourTable[Fee Change])
)

 

I'm not sure if SELECTEDVALUE will work in your scenario, so feel free to swap this for MAX or MIN or similar.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thanks for that, @BA_Pete. Sadly, no joy. 
Measure:

arpost_3-1626448221626.png

 

Result:

arpost_0-1626447803785.png

I did a little auditing and confirmed that the values in question don't have entries for specific dates. Using a table, I selected a % Change Date, which filtered to $0 for the Values because there were no values entered on 6/20/19.

 

arpost_2-1626447953335.png

 

OK, then maybe something like this:

 

_yourPercentageMeasure = 
VAR __maxDate =
CALCULATE(
    MAX(changeEvent[Date]),
    ALL(changeEvent)
)
RETURN
CALCULATE(
    MAX(changeEvent[Percentage]),
    FILTER(
        changeEvent,
        changeEvent[Date] = __maxDate
    )
)

 

 

I'm assuming here that your changeEvent table is related to your calendar table from which the shared date axis comes.

 

I seem to get the required output (I had to change the dates to fit with my calendar)

BA_Pete_0-1626450365381.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




That did it, @BA_Pete! I had to make some edits to make it start with the MIN date (and will probably need to make more for the max), but it is now performing as expected:

arpost_0-1626450667511.png

 

Here is a sanitized version of the code:

 

Percentage Change = 
VAR minDate =
CALCULATE(
MIN(Values[Date]),
ALL(Values)
)
RETURN
CALCULATE(
MAX('Change Event'[Percentage]),
FILTER(
'Change Event',
'Change Event'[Date] >= minDate
)
)

 


Thanks again; you're the best.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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