# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

## how to show data of last 7 days in bar chart

Hi,

I have an order table with a field OrderDate, a field Units and a field Price.

I created a bar chart and used OrderDate as dimension and sum(Units*Price) as measure.

The bar chart now shows all the order dates and the sum of Unit*Price for each day.

What I want to achieve is, that the bar chart only shows the last 7 days before today.

What is the best way to achieve this?

1 Solution

Accepted Solutions
Contributor III

## Re: how to show data of last 7 days in bar chart

Hi Dirk

if you using Qlik Sense, you can achieve what you want only by Set Analysis because you don't have the same options like in QlikView.

e.g.

Sum({\$<OrderDate={">=\$(=Today()-7)<=\$(=Today()-1)"}>}Units*Price) (when your date field is in num format e.g 42151)

or

Sum({\$<OrderDate={">=\$(=Date(Today()-7))<=\$(=Date(Today()-1))"}>}Units*Price) (when in date format e.g.  YYYY/MM/DD )

Let me know if it's working or not.

If not, it would be good to share some sample data if possible.

Regards,

Ronny

9 Replies
MVP

## Re: how to show data of last 7 days in bar chart

A simple approach would be to sort Date desc, then go to dimension limit tab and enable 'Restrict which values..' using option 'Show only first 7 values'.

You can also limit the dimension values by a calculated dimension or by a set expression in your aggregation expression.

Esteemed Contributor III

## Re: how to show data of last 7 days in bar chart

Hello Dirk,

Do you want this from QlikView or Qlik Sense? I believe what Stefan is describing is for QlikView.

Regards,

Mike Tarallo

Qlik

Contributor III

## Re: how to show data of last 7 days in bar chart

Hi Dirk

if you using Qlik Sense, you can achieve what you want only by Set Analysis because you don't have the same options like in QlikView.

e.g.

Sum({\$<OrderDate={">=\$(=Today()-7)<=\$(=Today()-1)"}>}Units*Price) (when your date field is in num format e.g 42151)

or

Sum({\$<OrderDate={">=\$(=Date(Today()-7))<=\$(=Date(Today()-1))"}>}Units*Price) (when in date format e.g.  YYYY/MM/DD )

Let me know if it's working or not.

If not, it would be good to share some sample data if possible.

Regards,

Ronny

Esteemed Contributor III

## Re: how to show data of last 7 days in bar chart

Dirk,

Ronny is correct - he beat me to it - if you are new to Set Analysis - you can learn more here:

A Beginners' Introduction to Set Analysis (video) - Part 1 and 2

Available from this series: New to Qlik Sense Videos

Regards,

Mike Tarallo

Qlik

Contributor III

## Re: how to show data of last 7 days in bar chart

Hi Michael

To say that I beat you is a bit exaggerated. I was maybe a little bit faster with typing this time.

But I also learnt this just from this great community.

e.g.

A Primer on Set Analysis

from hic

Best regards,

Ronny

Not applicable

## Re: how to show data of last 7 days in bar chart

Hi guys,

yes, I use Sense. Sorry for not mentioning.

Perfect! Ronnys 2nd Set Analysis expression did it for me.

I had tried a rather similar expression before my post here but couldn't do it. I'm still struggling a bit with the syntax of the set analysis, though I read and watches almost all the posts, videos and docs about it. But I am learning and you showed me a great way to achieve my goal. Thanks for that.

Seeing that this community is really working very well, I hope you can help me using this discussion board in the right way. Some days ago I posted a question in the sense app development forum (problem with master calendar and filtered data) and did not get any answer until now. I fear that I perhaps should have posted it in the New to Click Sense forum instead or that I did something wrong in my description. Do you think I should re-post this in the New to forum or change my question?

Thanks again

Dirk

Contributor III

## Re: how to show data of last 7 days in bar chart

Hi Dirk,

good to hear that the expression works.

I`m a little bit busy now but I will check your other post & will let you know when I find a solution or a good reason why it's not working. ^^

Regards,

Ronny

Not applicable

## Re: how to show data of last 7 days in bar chart

Thanks Ronny

Esteemed Contributor III

## Re: how to show data of last 7 days in bar chart

Hi Drik,

All Qlik Community discussions display in a list in the appropriate section, it depends on which members are monitoring or following. I monitor the New to Qlik Sense section on a regular basis and will get an alert when a new post is placed, I try to help as many people as possible and only to get to so many in addition to "Qlik" related work. :-)  However, feel free to reach out to a moderator / admin such as myself mto‌ anytime. I'll do my best to help, or at least put a set of eyes on ti.

Regards,

Mike Tarallo

Qlik