If we have a coupon code that say gives a 5% discount....how can I grab the discounted value into a variable? For example $100 subtotal with a 5% discount. The value of the discount would be 5. I need to get the "5" into a variable.
Based on this answer Magento Checkout : Get Subtotal Value without iterating
I was able to add another variable for discount:
$discount = $totals["discount"]->getValue();
Related
I have sales rep column, and their total sales. i am showing the results in the below matrix
so the actual value that i am trying to show from the calculated column as below.
FinalActual = if('Sales Target'[SalesRep] = "ABC",'Sales Target'[totalABC],'Sales Target'[totalseats]-'Sales Target'[totalseatspq] )
so I am trying to show the actual value based on the sales rep name. if the sales rep name is "ABC", then it should show the value of the measure which I created separately. for others it should be Sales Target'[totalseats]-'Sales Target'[totalseatspq]. But the issue here is, for ABC it's not taking the value from the "true condition(Sales Target'[totalABC])" of if statement. its still picking the value of the false condition(Sales Target'[totalseats]-'Sales Target'[totalseatspq]). Please help if I am missing anything here.
Your help is highly appreciated
I have a column called "Normalize Data" which has 2 values "yes" and "no".
Requirement:
When the user clicks on "yes", I want my measure(called Prev_YR_Trans) to do one thing, but if the user clicks "no" I want the measure to do another thing.
Let me explain with an example - My measure Prev_YR_Trans displays the transactions for the previous time period. Let's the say current time period is "25", then it will display the transactions for time period "24". Now, if the user clicks on "Yes", then I want the previous year's transactions to get "normalized" i.e. I want it to get multiplied by the variance b/w the 2 time periods.
What I have tried:
Prev_YR_Trans =
#getting the current & previous time period from Table "X"
VAR prevSeason = CALCULATE(MAX('X'[Time Period]))-1
VAR maxSeason = CALCULATE(MAX('X'[Time Period]))
#getting variance b/w prev and current time periods
VAR maxSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=maxSeason)
VAR prevSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=prevSeason)
VAR footfall_variance = 1+((maxSeason_footfall-prevSeason_footfall)/prevSeason_footfall)
#trying to get the option that the user clicks on(?)
VAR bb = CALCULATE(('X'[Normalize data]))
#returns normalized numbers if user chooses "Yes" else returns actual numbers
RETURN
IF(bb="Yes",
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)*footfall_variance,
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)
)
In my above measure, the "VAR bb = CALCULATE(('X'[Normalize data]))" is giving me an error as it needs some aggregation like max,min,sum,etc.
How do I resolve my measure so that it displays the correct numbers?
Edit (Solved) More on "Normalize Data" column:
I've solved the "Normalize Data" column by creating a new table called "Normalize Slicer" with yes/no values. Here is the link
Also, if you could help me out with my "Normalize Data" column too then that would great!
So with the "Normalize Data" column - I just want it to display 2 options "Yes" and "No" but I realized I need to create it as a column for the slicer functionality to work.
So for my formula I'd like to display "Yes" if the "Time Period" is less than or equal to the previous time period and "No" otherwise.
I tried to do the following:
Normalize data = IF('X'[Time Period]<=(CALCULATE(MAX('X'[Time Period]))-1),"Yes","No")
But above column just displays "No" for all the values so as a workaround I manually entered the previous time period in the formula:
Normalize data = IF('X'[Time Period]<=24,"Yes","No")
The above formula does work but I'd like it to be dynamic and not a manually entered value.
Insted of
VAR bb = CALCULATE(('X'[Normalize data]))
Use this:
var bb = SELECTEDVALUE('X'[Normalize data])
https://dax.guide/selectedvalue/
I have data like this brought into a SPICE from Redshift:
BadgeAward StartDate EndDate
Bronze 1/15/2017 1/15/2020
Silver 2/15/2019 2/15/2020
Gold 3/15/2017 3/15/2020
Gold 3/15/2017 3/15/2020
I am putting a line graph to show at a point in time (StartDate), how many are active
At 1/15/2017, Total Badges = 1 (Only Bronze is active)
At 2/15/2019, Total Badges = 4 (Gold,Bronze and Silver are still active)
At 3/15/2017, Total Badges = 3 (Gold and Bronze are active, Silver has not started yet)
I have been playing around with RunningCount but cannot seem to get it right.
I recreated your data set and what I thought would work with a runningcount formula. As you pointed out, it doesn't seem to work. QuickSight appears to be applying a distinct_Count logic as a part of the runningcount formula instead of a pure count.
To get around the issue I create a separate calculated field in which I assigned a value of 1 to assign a 1 to every row in the data. Then I did a runningsum formula based off that field to get your desired output.
BadgeCount = runningsum(sum(1),[STartDate ASC],[])
I got a situation here, i have a measure for "Total Sales" with following expression
Total Sales = CALCULATE(SUM(Sale[total]), ALL(Customer))
I have a visualization in which i am displaying product-sales by customer.
If i make a customer-name selection in that visualization then this measure (mentioned above) changes its value. Why?
Both scenarios are shown in following screenshot (measure-value without customer-name selection & measure value with customer-name selection:
Data-Model Screenshot:
I changed the formula to ignore both tables
Total Sales = CALCULATE(SUM(Sale[total]), ALL(Customer), ALL(Product))
Main questions I have:
RegEx practices for statements that are close but not similar iterated through a list of websites when dealing with doubles and text
Should I pull all of the text then parse out what I want in the following code? Or is there a better way?
I am currently trying to extract interest rate data from different lenders using regular expression. I want to use regex because I want to be able to add more URLs as more lenders arise. I want the extracted information to basically take on the form of:
x.xx% - xx.xx% (the low - high bands of the interest rates)
Most of the websites vary in how they present this, some examples:
APR ranges from x.xx% to xx.xx%
Rates range from x.xx% to xx.xx%
x.xx% - xx.xx%
range from x.xx% (AA) to xx.xx% (HR)
Currently I am trying to just grab the paragraph the text lives in and then make substrings off of that to create the final piece of information I need (x.xx% - xx.xx%). Not sure if this is the best method, but would like to crowdsource my issue.
plcompetitors = ['https://www.lendingclub.com/loans/personal-loans',
'https://www.marcus.com/us/en/personal-loans',
'https://www.discover.com/personal-loans/',
'https://www.lightstream.com/',
'https://www.prosper.com/']
#cycle through links in array until it finds APR rates/fixed or variable using regex
for link in plcompetitors:
l = r.get(link)
l.encoding = 'utf-8'
data = l.text
soup = bs(data, 'html.parser')
paragraph = soup.body.findAll(text=re.compile('% APR'))
#using this next if statement to try and iterate through what turned up empty in the initial pass through with the first .compile statement
if paragraph == []:
paragraph = soup.body.findAll(text=re.compile('% - [0-9]'))
print(paragraph)
Which returns this:
[]
[]
[' 6.99% to 24.99% APR']
['\r\n Payment example: Monthly payments for a $10,000 loan at 3.09% APR with a term of 3 years would result in 36 monthly payments of $291.21.', 'The lender’s interest rate (APR) must not be supported by any third-party arrangements such as vehicle manufacturer subvention payments (with rates as low as 0.0% APR), other manufacturer discounts, rate buy-downs by car buying services or any other\n similar third-party subsidized rate offerings.']
['* For example, a three-year $10,000 loan with a Prosper Rating of AA would have an interest rate of 5.31% and a 2.41% origination fee for an annual percentage rate (APR) of 6.95% APR. You would receive $9,759 and make 36 scheduled monthly payments of $301.10. A five-year $10,000 loan with a Prosper Rating of A would have an interest rate of 8.39% and a 5.00% origination fee with a 10.59% APR. You would receive $9,500 and make 60 scheduled monthly payments of $204.64. Origination fees vary between 2.41%-5%. APRs through Prosper range from 6.95% (AA) to 35.99% (HR) for first-time borrowers, with the lowest rates for the most creditworthy borrowers. Eligibility for loans up to $40,000 depends on the information provided by the applicant in the application form. Eligibility is not guaranteed, and requires that a sufficient number of investors commit funds to your account and that you meet credit and other conditions. Refer to Borrower Registration Agreement for details and all terms and conditions. All loans made by WebBank, member FDIC.']