Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hi,
Could you please help with the following problem I have faced?
I have two measures [Sales] and [Expired], which are simply summing column values. I need a new measure that would recalculated [Expired] measure. Logic is better explained with an example.
When user selects User_sales = User 1, I would like to have [Expired] measure recalculated by removing filter from User_sales column and filtering the same user in User_expirations column.
row | User_sales | User_expirations | Year_Month | Sales | Expired |
1 | User 1 | User 1 | 2020-05 | 1425 | |
2 | User 1 | User 2 | 2020-05 | 536 | |
3 | User 1 | User 1 | 2020-07 | -536 | |
4 | User 1 | User 1 | 2020-07 | 458 | |
5 | User 2 | User 1 | 2019-05 | 86 | |
6 | User 2 | User 1 | 2020-05 | -1852 | |
7 | User 2 | User 1 | 2020-05 | -86 | |
8 | User 2 | User 2 | 2018-09 | 1312 | |
9 | User 2 | User 2 | 2019-05 | -1312 | |
10 | User 2 | User 3 | 2019-05 | 1996 | |
11 | User 2 | User 3 | 2019-10 | 1211 | |
12 | User 3 | User 1 | 2019-10 | 800 | |
13 | User 3 | User 1 | 2020-05 | -523 | |
14 | User 3 | User 1 | 2020-05 | -800 |
As a result, for above table, if User_sales = "User 1" is selected, then [Expired_new] measure would sum not only those values in row 3 and 4, but also all all other values next to "User 1" in User_expirations column (marked in blue).
Is it at all possible?
Solved! Go to Solution.
@acekalina wrote:
Hi @dedelman_clng for:
- User 1 should be -536 + 458 + (-1 852) + (-86) = -2 016
Remove "SUM ( ExSales[Sales] ) +" from the code.
According to your data it should be -536 + 458 + (-1852) + (-86) + (-523) + (-800) = -3339.
Expired_New =
VAR __user =
SELECTEDVALUE ( ExSales[User_sales] )
RETURN
CALCULATE (
SUM ( ExSales[Expired] ),
FILTER ( ALL ( ExSales ), ExSales[User_expirations] = __user )
)
Also, my PowerBI Desktop does not recognise SELECTEDVALUE function.
For this I'm not sure how to help. You may have typed something wrong. Please share your report file with sensitive data scrubbed if you are still having issues.
Hi @acekalina - does this meet your needs?
Expired_New =
VAR __user =
SELECTEDVALUE ( ExSales[User_sales] )
RETURN
CALCULATE (
SUM ( ExSales[Sales] ) + SUM ( ExSales[Expired] ),
FILTER ( ALL ( ExSales ), ExSales[User_expirations] = __user )
)
If not, please tell us what values you are expecting for Expired_New
Hope this helps
David
Hi @dedelman_clng for:
- User 1 should be -536 + 458 + (-1 852) + (-86) = -2 016
- User 2 should be -1 312
- User 3 should be 1 211
Basically, Expired_New should show results against User_sales, although they are linked to User_expirations. I do not need to add Sales numbers there, just to see Sales and Expirations against users from one column.
Also, my PowerBI Desktop does not recognise SELECTEDVALUE function.
@acekalina wrote:
Hi @dedelman_clng for:
- User 1 should be -536 + 458 + (-1 852) + (-86) = -2 016
Remove "SUM ( ExSales[Sales] ) +" from the code.
According to your data it should be -536 + 458 + (-1852) + (-86) + (-523) + (-800) = -3339.
Expired_New =
VAR __user =
SELECTEDVALUE ( ExSales[User_sales] )
RETURN
CALCULATE (
SUM ( ExSales[Expired] ),
FILTER ( ALL ( ExSales ), ExSales[User_expirations] = __user )
)
Also, my PowerBI Desktop does not recognise SELECTEDVALUE function.
For this I'm not sure how to help. You may have typed something wrong. Please share your report file with sensitive data scrubbed if you are still having issues.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.