Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
To whom that can help,
Below is a snip of my data:
I want to calculate the percetange change as well as the numerical +/- value for the Current Due, 31-60, 61-90, Over 90 & Balance Due column for each customer (cust. no) from today's date to the previous date.
Please let me know what other information you need.
Solved! Go to Solution.
We should only need to update the PreDate to the date of 7 days ago.
Change_7 = VAR CurrentDate = Table1[Date] VAR PreDate = CurrentDate - 7 VAR PreDue = LOOKUPVALUE ( Table1[Current Due], Table1[Date], PreDate, Table1[Cust No], Table1[Cust No], Table1[Branch], Table1[Branch] ) RETURN ( IF ( PreDue <> BLANK (), Table1[Current Due] - PreDue ) )
Best Regards,
Herbert
I’m not sure how do you want to calculate the percentage change. Only Current Due column has numerical values in your table. So I used this column to do the calculation. I use the current day due subtract the previous day due, and divide previous day due. Maybe the calculation is not completely same as you desired, but should be similar.
Percent = VAR CurrentDate = Table1[Date] VAR PreDate = CALCULATE ( MAX ( Table1[Date] ), FILTER ( Table1, Table1[Date] < CurrentDate ) ) VAR PreDue = LOOKUPVALUE ( Table1[Current Due], Table1[Date], PreDate, Table1[Cust No], Table1[Cust No] ) RETURN ( IF ( PreDue <> BLANK (), ( Table1[Current Due] - PreDue ) / PreDue ) )
31 - 60 = IF ( ABS ( Table1[Percent] ) > 0.31 && ABS ( Table1[Percent] ) < 0.6, ABS ( Table1[Percent] ) )
Best Regards,
Herbert
Thanks again. I just attempted to model my data and add the new "Percentage" column. I am getting the following error:
@JCBI1023 check what DATA Type your Sheet1[Date] column is? it looks like it is text instead of date?
For a quick visual reference date/numbers will always be right-justified in the column while text will be left-justified
Change the Data Type in the Modeling tab
According to the warning message, it seems there are multiple Branches have the same Cust No and Date. You can try to update the column formula as below to restrict Branch.
Percent = VAR CurrentDate = Table1[Date] VAR PreDate = CALCULATE ( MAX ( Table1[Date] ), FILTER ( Table1, Table1[Date] < CurrentDate ) ) VAR PreDue = LOOKUPVALUE ( Table1[Current Due], Table1[Date], PreDate, Table1[Cust No], Table1[Cust No], Table1[Branch], Table1[Branch] ) RETURN ( IF ( PreDue <> BLANK (), ( Table1[Current Due] - PreDue ) / PreDue ) )
Best Regards,
Herbert
@v-haibl-msft - You're exactly right. One customer can have balances in different branches, but totaling will be acceptable, as they collect per customer, not branch.
I will attempt this tomorrow. Thank you very much,
@JCBI1023 I agree with @v-haibl-msft
Here's my response from last week regarding the same exact error type
The error you are getting indicates that the LOOKUPVALUE function encounters multiple possible answers in your data set
when its looking to return only one!
@v-haibl-msft Thank you for the %. The second part of my question was how to calcute the numerical change from the previous day to the current day.
For example, if the Current Due for Customer X on Oct 19th was $500 and today it is $100... I need that number.
To give you some background, I am using the Power BI in accordance with my Office365 subscription. It is the free version.
Each day at 5PM I run an AR Aging Report against our Business System and it gives me the current aging. Then I populate my source spreadsheet with the information and date each line. I then refresh my PowerBI report and update the Report Level filter to the current date, The next morning the Managers can look at the published report and the numbers will be current as of 5PM the previous day. That's working well. Now they want to see the change between current day and previous day.
Just try with following column expression, it should be almost same as the percent column expression.
Numerical Change = VAR CurrentDate = Table1[Date] VAR PreDate = CALCULATE ( MAX ( Table1[Date] ), FILTER ( Table1, Table1[Date] < CurrentDate ) ) VAR PreDue = LOOKUPVALUE ( Table1[Current Due], Table1[Date], PreDate, Table1[Cust No], Table1[Cust No], Table1[Branch], Table1[Branch] ) RETURN ( IF ( PreDue <> BLANK (), Table1[Current Due] - PreDue ) )
Best Regards,
Herbert
@v-haibl-msft Thank you so much for this. One final change, I promise. Then I will make this as solved.
The formula to find the numerical change in value for the previous day worked great. Now, what if I wanted to find the the change for the week? In other words, take the current day's value and subtract it from what the value was 7 days ago.
Thank you again.
We should only need to update the PreDate to the date of 7 days ago.
Change_7 = VAR CurrentDate = Table1[Date] VAR PreDate = CurrentDate - 7 VAR PreDue = LOOKUPVALUE ( Table1[Current Due], Table1[Date], PreDate, Table1[Cust No], Table1[Cust No], Table1[Branch], Table1[Branch] ) RETURN ( IF ( PreDue <> BLANK (), Table1[Current Due] - PreDue ) )
Best Regards,
Herbert
This is wonderful! Management wants one more thing and I can't figure out how to formulate the number.
You have helped me find the change from the current due to the current due 7 days ago. Now I simpy need the current due number from 7 days ago. So I will have Current, Previous (from 7 days ago), Change....
I think I may have answered my own question, would it just be:
Previous Current Due =
VAR CurrentDate = Sheet1[Date]
VAR PreDate = CurrentDate - 7
VAR PreDue =
LOOKUPVALUE (
Sheet1[Current Due],
Sheet1[Date], PreDate,
Sheet1[Cust No ], Sheet1[Cust No ],
Sheet1[Branch], Sheet1[Branch]
)
RETURN
(
IF ( PreDue <> BLANK (), PreDue )
)
@v-haibl-msft @Herbert_Liu
Hello, when calculating the previous day, using this login : VAR PreDate = CurrentDate - 1 ...
61-90 Previous Day =
VAR CurrentDate = Sheet1[Date]
VAR PreDate = CurrentDate - 1
VAR PreDue =
LOOKUPVALUE (
Sheet1[61 - 90],
Sheet1[Date], PreDate,
Sheet1[Cust No ], Sheet1[Cust No ],
Sheet1[Branch], Sheet1[Branch]
)
RETURN
(
IF ( PreDue <> BLANK (), PreDue )
)
Since I do not update this on Saturday or Sunday, when Monday comes around there is no previous day, it is blank. How do I tell the formula to skip Saturday or Sunday, or if there isn't a "Previous day" then look for the value that is the previous regardless of how many days away it was.
Thank you for your reply. From the snippet, you are correct, onlt the Current Due column has numerical values. However, farther down in the dataset, values do exist for the other columns. Let me give this a shot and get back to you.
Hi There,
I have used the PowerQuery to find the solution of your problem. However, this is not the one & only apporach. You can also use SWITCH or IF function in DAX to find the answer. I demonstrated to you in this example what powerquery can do in PowerBI.
Please follow the screenshots to calculate the right answer.
You can also use powerquery to count the percentage change.
Many thanks for your detailed answer. I will attempt to give this a shot today.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
97 | |
80 | |
67 | |
63 |
User | Count |
---|---|
147 | |
110 | |
108 | |
85 | |
64 |