cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Frequent Visitor

## Getting goal as blank and distance as infinity in kpi visual for calculated previous period measure.

Hi,

I am working on a dashboard, in which I am trying to implement a KPI visual for current period vs previous period values. The visual works correct for the end date upto 31st December 2016. But when I change my end date to any date from january 2017 KPI visual starts me showing goal as blank and distance as infinite forselected end date from january 2017.Here I am attaching the

screenshots from the test file.So can any one please help me to find any solution on this..??

End date is of December 2016After selecting End date from january 2017

1 ACCEPTED SOLUTION
Employee

Please try with following two DAX measures. And drag ‘public facebook_page_data’[Date] into the KPI visual.

```Cur_Period_Total =
VAR FirstD =
MIN ( 'Date select'[Date] )
VAR LastD =
MAX ( 'Date select'[Date] )
RETURN
CALCULATE (
FILTER (
)
)```
```Pre_Period_Total =
CALCULATE (
DATESBETWEEN (
'Date select'[Date],
MIN ( 'Date select'[Date] ) - 'Date select'[Selected_Days],
MIN ( 'Date select'[Date] ) - 1
)
)```

Best Regards,

Herbert

7 REPLIES 7
Memorable Member

What is meaning of Previous Period Clicks  and fomula to calcualte it? I think your expression for Previous Period Clicks  is not correct so with 2017, it returns blank and making % infinity

Employee

If we change end date to 1/1/2017, 1/2/2017…1/5/2017, the KPI visual will not show goal as blank and distance as infinite.

I have a question about the Previous Period Clicks measure, how do you want to calculate it? Is current DAX formula correct?

Best Regards,

Herbert

Frequent Visitor

I have calculated the Previous Period Clicks measure on the basis of date diffrence from current period context dates.I have used the following formulas to calculate the measure.

1)Start Date = MIN('Date select'[Date])

2)End Date = MAX('Date select'[Date])

3)DateDiff = DATEDIFF([Start Date],[End Date],DAY)+1

I have calculted a measure for every formulas mentioned above.The Previous Period Clicks measure returned correct value to me for selectd date range in date filter.I have verified it by using card visual and the values from database.My objective is to get previous period values.

For example:

If I select 7 days date diffrence in date filter;then my calculated previous period measure must return me the values of last 7 days from the start date that I have selectd in date filter.

Best Regards,

Employee

In your table of “public facebook_page_data”, the last date is 1/4/2017. The measure of “Previous Period Clicks” will always return the Clicks in previous day of the max selected date.

For example, if we select date range from “3/2/2016” to “1/5/2017”, “Previous Period Clicks” will return the Clicks in 1/4/2017 and it is 1294.

If you select date range from “3/2/2016” to “1/6/2017”, since there is no data for “1/5/2017”, then “Previous Period Clicks” will return blank.

Best Regards,

Herbert

Frequent Visitor

Thank you for your reply. As per example given by you if I select date range from “3/2/2016” to “1/5/2017” the date difference is 310 days. Then the goal value of previous period must return the sum of clicks between "4/27/2015" and “3/1/2016”. But as the dates before "1/1/2016" are not present in the database so it must consider the Clicks for dates before  "1/1/2016" as zero and must return the sum of clicks from dates "1/1/2016" to  “3/1/2016”. But the value we are  getting in example given by you for previous period clicks is 1294.  which is the on date “1/4/2017”.

Best Regards,

Employee

Please try with following two DAX measures. And drag ‘public facebook_page_data’[Date] into the KPI visual.

```Cur_Period_Total =
VAR FirstD =
MIN ( 'Date select'[Date] )
VAR LastD =
MAX ( 'Date select'[Date] )
RETURN
CALCULATE (
FILTER (
)
)```
```Pre_Period_Total =
CALCULATE (
DATESBETWEEN (
'Date select'[Date],
MIN ( 'Date select'[Date] ) - 'Date select'[Selected_Days],
MIN ( 'Date select'[Date] ) - 1
)
)```

Best Regards,

Herbert

Frequent Visitor

Thank you for the solution it worked for me.

Best Regards,

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors