The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I have two tables "PriceList" and "DiscountList" with following fields
1. PriceList:
ProcessNumber (1601, 1602, 1629, 1920...)
Type (A, B, C, D, ....)
Shipment value interval (0-50, 50-100, 100-200, 0-150, 150-500, ...)
Price for shipment
2.DiscountList:
Type (A, B, C, D,....)
DiscountGroup (101, 201, 301, 205, 310,...)
DiscountPercent
Currently the two tables ar linked with many-to-many relationship. Perhaps it should be changed and have a separate dimension table. Please suggest.
Eventually, in the visual part, I would like to be able to select one DiscountGroup, and see in matrix or table all records from the "PriceList" table but with applied discount (based on the selected DiscountGroup and on Type) to the field "Price for shipment".
The simple version would be a measure:
DiscountedPrice = [Price for shipment]*(1-[DiscountPercent]).
However, how to establish this relationship between the two tables, so that the measure understands what I need.
If no DiscountGroup is selected or more than one is selected, matrix/table should not show any value or show 0 or error message.
Solved! Go to Solution.
Hi @AsnateKalnina,
You may try this solution.
1 Make the relationship inactive
2 Create a Measure like this
DiscountedPrice =
VAR selectedDiscountGroup =
COUNTROWS ( ALLSELECTED ( DiscountList[DisountGroup] ) )
VAR discountPrice =
CALCULATE (
MAX ( 'PriceList'[Price for shipment] )
* ( 1 - MAX ( 'DiscountList'[DiscountPercent] ) ),
USERELATIONSHIP(DiscountList[Type], PriceList[Type] )
)
VAR checkDiscountPrice =
IF ( ISBLANK ( discountPrice ), "", discountPrice )
RETURN
IF (
selectedDiscountGroup = 0
|| selectedDiscountGroup > 1,
BLANK (),
checkDiscountPrice
)
The result looks like this.
Also, attached the pbix file as reference.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi @AsnateKalnina,
You may try this solution.
1 Make the relationship inactive
2 Create a Measure like this
DiscountedPrice =
VAR selectedDiscountGroup =
COUNTROWS ( ALLSELECTED ( DiscountList[DisountGroup] ) )
VAR discountPrice =
CALCULATE (
MAX ( 'PriceList'[Price for shipment] )
* ( 1 - MAX ( 'DiscountList'[DiscountPercent] ) ),
USERELATIONSHIP(DiscountList[Type], PriceList[Type] )
)
VAR checkDiscountPrice =
IF ( ISBLANK ( discountPrice ), "", discountPrice )
RETURN
IF (
selectedDiscountGroup = 0
|| selectedDiscountGroup > 1,
BLANK (),
checkDiscountPrice
)
The result looks like this.
Also, attached the pbix file as reference.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Brilliant!
Thank you very much!
Excellent job- a big help for me!
Could you please show some pictures of your model and data? The data can be anonymized, if you don't want to show what you've got. A picture is worth a thousand words, so they say and rightly so 🙂
If you want some hints... How to Get Your Question Answered Quickly (powerbi.com)
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |