cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
9192gks
Helper III
Helper III

KPI calculated measure

I asked this question before but i didn't explained it properly.
so i have a table( "TABLE 1") having 4 columns, i wanted to created an kpi using Line and clustered column chart.

the table contains target for different SBU for different months of the year 2020.

send2.PNG

I have created another table with same column names,but the SBU is empty along with target.(TABLE 2)
send1.PNG

So In my line and clustered column chart when no SBU is selected it should show values from Table 2 and when SBU is selected it should show the Maximum value of that particular SBU for all the months.
send3.png

but i don't know how to create a measure for this particular problem.In the above visual when No SBU is selected it is supposed to show 94.40 % for the month of january from TABLE 2 ,Instead it's showing 94.20% because it's taking the average of all SBU for the month january of TABLE 1

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @9192gks 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

v-alq-msft
Community Support
Community Support

Hi, @9192gks 

 

Based on your description, I created data to reproduce your scenario.

Tab:

g1.png

Table:

g2.png

 

You may create two measures as below.

 

 

Target measure = 
var _month = SELECTEDVALUE('Table'[Month].[Month])
var _sbu = SELECTEDVALUE(Tab[SBU])
return
IF(
    NOT(ISFILTERED(Tab[SBU])),
    CALCULATE(
        SUM('Table'[Target]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Month].[Month] = _month
        )
    ),
    IF(
        HASONEVALUE(Tab[SBU]),
        CALCULATE(
            MAX(Tab[Target]),
            FILTER(
                ALLSELECTED(Tab),
                Tab[SBU] = _sbu&&
                Tab[Month].[Month] = _month
            )
        )
    )
)

KP measure = 
var _month = SELECTEDVALUE('Table'[Month].[Month])
var _sbu = SELECTEDVALUE(Tab[SBU])
return
IF(
    NOT(ISFILTERED(Tab[SBU])),
    CALCULATE(
        SUM('Table'[KP]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Month].[Month] = _month
        )
    ),
    IF(
        HASONEVALUE(Tab[SBU]),
        CALCULATE(
            MAX(Tab[KP]),
            FILTER(
                ALLSELECTED(Tab),
                Tab[SBU] = _sbu&&
                Tab[Month].[Month] = _month
            )
        )
    )
)

 

 

 

Result:

g3.png

g4.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.

amitchandak
Super User
Super User

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!