cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rax99 Member
Member

Dynamically change measure value depending on the axis and drill level

I have a simple chart like this:

 

salesTarget.JPG

 

Ignoring the stacked element, the bars show the measure [TotalSales]

 

I need to create a target line that is 80% of the measure value for the first month/year/day in the chart (depending on drill level)

 

For example, in the pic above I have harcoded the value at 28000 (based on totalsales for March) so it shows a straight target line. across. How do I create a measue that does this and dynamically changes based on the first day or month or year and also dynamically changes depending on the level drilled?

 

Ive tried something like this but to no avail:

TargetSales = VAR SALESMARCH = CALCULATE(SUM(Sales[TotalSales]),CALENDAR("20180301","20180330"))
              VAR PERCENT80 = SALESMARCH*0.8
              RETURN PERCENT80
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Dynamically change measure value depending on the axis and drill level

Hi @rax99,

 

I made one sample for your reference.

 

1. Create a date table and create relationship with the fact table.

 

2, To create a calculated column in the fact table.

 

YEARMONTH = YEAR('Table1'[date])*100 +MONTH('Table1'[date])

3. Create a measure as below.

 

mea =
VAR countr =
    CALCULATE ( DISTINCTCOUNT ( 'Table1'[date] ), ALLSELECTED ( Table1[date] ) )
VAR countrm =
    CALCULATE ( DISTINCTCOUNT ( 'Table1'[date] ), ALL ( Table1 ) )
VAR mindate =
    CALCULATE ( MIN ( 'Table1'[date] ), ALL ( Table1 ) )
VAR maxdate =
    CALCULATE ( MAX ( 'Table1'[date] ) )
RETURN
    IF (
        ISBLANK ( countr ),
        BLANK (),
        IF (
            countr > 1
                && countr < countrm,
            CALCULATE (
                SUM ( Table1[amount] ),
                FILTER (
                    ALL ( Table1 ),
                    Table1[YEARMONTH]
                        = YEAR ( mindate ) * 100
                            + MONTH ( mindate )
                )
            )
                * 0.8,
            IF (
                countr = 1,
                CALCULATE (
                    SUM ( Table1[amount] ),
                    FILTER ( ALL ( Table1 ), 'Table1'[date] = mindate )
                )
                    * 0.8,
                CALCULATE ( SUM ( Table1[amount] ), ALL ( Table1 ) ) * 0.8
            )
        )
    )

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

 

 

 

Community Support Team _ Frank
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

2 REPLIES 2
Highlighted
Community Support Team
Community Support Team

Re: Dynamically change measure value depending on the axis and drill level

Hi @rax99,

 

I made one sample for your reference.

 

1. Create a date table and create relationship with the fact table.

 

2, To create a calculated column in the fact table.

 

YEARMONTH = YEAR('Table1'[date])*100 +MONTH('Table1'[date])

3. Create a measure as below.

 

mea =
VAR countr =
    CALCULATE ( DISTINCTCOUNT ( 'Table1'[date] ), ALLSELECTED ( Table1[date] ) )
VAR countrm =
    CALCULATE ( DISTINCTCOUNT ( 'Table1'[date] ), ALL ( Table1 ) )
VAR mindate =
    CALCULATE ( MIN ( 'Table1'[date] ), ALL ( Table1 ) )
VAR maxdate =
    CALCULATE ( MAX ( 'Table1'[date] ) )
RETURN
    IF (
        ISBLANK ( countr ),
        BLANK (),
        IF (
            countr > 1
                && countr < countrm,
            CALCULATE (
                SUM ( Table1[amount] ),
                FILTER (
                    ALL ( Table1 ),
                    Table1[YEARMONTH]
                        = YEAR ( mindate ) * 100
                            + MONTH ( mindate )
                )
            )
                * 0.8,
            IF (
                countr = 1,
                CALCULATE (
                    SUM ( Table1[amount] ),
                    FILTER ( ALL ( Table1 ), 'Table1'[date] = mindate )
                )
                    * 0.8,
                CALCULATE ( SUM ( Table1[amount] ), ALL ( Table1 ) ) * 0.8
            )
        )
    )

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

 

 

 

Community Support Team _ Frank
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

Community Support Team
Community Support Team

Re: Dynamically change measure value depending on the axis and drill level

Hi @rax99,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.


Regards,
Frank

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 65 members 1,241 guests
Please welcome our newest community members: