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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
darkmetrics
Helper I
Helper I

How to make a chart with with flexible sum of sales and conversion rate calculation?

 

Good afternoon!

I have a dataset with daily sales on a website over period between 2021 and 2022. It looks like:

darkmetrics_1-1662809193611.png

 

 

I want to do 2 things:

  1. I want to make a flexible chart that shows page views and sales dynamics for daily/weekly/monthly intervals. Weekly or monthly sales and page views should be calculated simply as a sum of daily observations from my data. The week starts on Monday and ends on Saturday. The frequency of data displayed on the chart should be controlled with a button. So I want to achieve something like:
    darkmetrics_3-1662809470608.png

     

2. I also want to show on this flexible chart dynamics of the conversion rate (number of purchases divided by the number of sales). I want the conversion rate to be flexible: that means, if the user selects "Weekly" frequency for the chart, # purchases and sales are summarized over each week and divided one by other. For instance, if sales over 1st week of 2021 are equal to 100, page views are equal to 50, then the conversion rate displayed on the chart should be 50% and so on for other weeks. If user of the dashboard selects "Daily" frequency, conversion rate is calculated simply as daily purchases divided by page views. If user selects the "Monthly" frequency for the chart, the purchases and the page views should sum up over the month and the conversion rate should be calculated in the same manner as for weekly or daily frequency.

 

How can I do (1) and (2) in the most efficient way with Power BI and DAX?

1 ACCEPTED SOLUTION

@darkmetrics So, yes, you could add the columns inside the DAX measure using ADDCOLUMNS. The conversion rate is a simple DIVIDE. So, for example, you could create a DAX measure like this:

Weekly Measure = 
  VAR __WeekNum = WEEKNUM(MAX('Dates'[Date]))
  VAR __Table =
    ADDCOLUMNS(
      'Table',
      "__WeekNum", WEEKNUM([date])
    )
  VAR __Views = SUMX(FILTER(__Table,[__WeekNum] = __WeekNum),[# page views])
  VAR __Purchases = SUMX(FILTER(__Table,[__WeekNum] = __WeekNum),[# purchases])
RETURN
  DIVIDE(__Purchases, __Views,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@darkmetrics Well, you will want to use WEEKNUM and MONTH to add columns for those in your table. You could use stacked visuals and bookmarks to swap out the visuals based upon the button pushed.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

1. Is it possible to do that without additional columns (using some filters in DAX measure)?

2. What would you say about conversion rate?

@darkmetrics So, yes, you could add the columns inside the DAX measure using ADDCOLUMNS. The conversion rate is a simple DIVIDE. So, for example, you could create a DAX measure like this:

Weekly Measure = 
  VAR __WeekNum = WEEKNUM(MAX('Dates'[Date]))
  VAR __Table =
    ADDCOLUMNS(
      'Table',
      "__WeekNum", WEEKNUM([date])
    )
  VAR __Views = SUMX(FILTER(__Table,[__WeekNum] = __WeekNum),[# page views])
  VAR __Purchases = SUMX(FILTER(__Table,[__WeekNum] = __WeekNum),[# purchases])
RETURN
  DIVIDE(__Purchases, __Views,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you, it works!

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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