Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi All,
I'm struggling with approach to calculate revenue per "dynamic" category which is based on period slicer selection. In case month granularity appears on chart show revenue per category monthly, if quarter - show revenue (sum of all revenue in quarter) per category, if year - show revenue (sum of all revenue in year) per category.
Have fact table with monthly granularity and relation to date table on date filelds.
Is it even possible to calculate such logic in Power BI?
Sample of data
Account | Date | Amount |
1111 | 1/1/2022 | $ 100 |
1111 | 2/1/2022 | $ 300 |
1111 | 3/1/2022 | $ 200 |
1111 | 4/1/2022 | $ 100 |
1111 | 5/1/2022 | $ 600 |
1111 | 6/1/2022 | $ 200 |
1111 | 7/1/2022 | $ 300 |
2222 | 1/1/2022 | $ 600 |
2222 | 2/1/2022 | $ 400 |
2222 | 3/1/2022 | $ 500 |
2222 | 4/1/2022 | $ 400 |
2222 | 5/1/2022 | $ 500 |
2222 | 6/1/2022 | $ 600 |
2222 | 7/1/2022 | $ 700 |
2222 | 8/1/2022 | $ 600 |
categoty values
small | mid | large |
<= 300 | > 300 <= 1000 | > 1000 |
Expected result
monthly aggregation
quarter aggregation
in case of year aggregation
Solved! Go to Solution.
@bsas , You need to consider Dynamic Segmentation, but buckets will static
Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...
Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k
Hi @bsas ,
I think you want to show two legends [Category] and [Amount] in Stacked column chart in Power BI. Currently, Power BI doesn't support us to add two legends directly. Here I suggest you to try Small multiples function.
Data model:
Measure:
Amount by Category =
SWITCH (
SELECTEDVALUE ( Category[Category] ),
"Small",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Mid",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 1000
&& CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Large",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 1000,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @bsas ,
I think you want to show two legends [Category] and [Amount] in Stacked column chart in Power BI. Currently, Power BI doesn't support us to add two legends directly. Here I suggest you to try Small multiples function.
Data model:
Measure:
Amount by Category =
SWITCH (
SELECTEDVALUE ( Category[Category] ),
"Small",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Mid",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) <= 1000
&& CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 300,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
),
"Large",
IF (
CALCULATE ( SUM ( 'Table'[ Amount ] ) ) > 1000,
CALCULATE ( SUM ( 'Table'[ Amount ] ) )
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@bsas , You need to consider Dynamic Segmentation, but buckets will static
Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...
Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k
Thank you @amitchandak ! I was moving in similar direction but your article inspired on new idea. At the end for my case I created separate table with ID and Label fields then created measure using switch and sumx.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
76 | |
56 | |
38 | |
34 |
User | Count |
---|---|
99 | |
56 | |
51 | |
44 | |
40 |