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.
Hello,
I want to build a report in PBI, that shows me the following information in a histogram:
- Axe X : Category, Subcategory
- Axe Y : Total amount
- Filter : Subcategory + Date
Is't possible to build this report ?
Thanks in advance.
Solved! Go to Solution.
Hi, @TotoBlank
Thanks for your response and detailed description for your question. I'm sorry i may make a mistake in this dax.
You can try to use dax to test:
Measure = var _flag= MAX('X Table'[Flag])
var _name = MAX('X Table'[Column1])
var _sub = CALCULATE( SUM('Table'[Amount]) ,KEEPFILTERS( TREATAS({_name} , 'Table'[Subcategory])))
var _cat = CALCULATE( SUM('Table'[Amount]) , TREATAS({_name} , 'Table'[Category]),ALL('Table'[Subcategory]) )
var _cat_table = VALUES('Table'[Category])
return IF(_flag = "CAT" && _name in _cat_table,_cat ,_sub)
Then we can meet your need:
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , @TotoBlank
Accoridng to your description, you want to show both cat and sub-cat in the visual.
Here are the steps you can refer to :
(1)This is my test data:
(2)We need to create a x-axis table in Power Query Editor, we can create a blank query in it and enter this:
= Table.AddIndexColumn(Table.AddColumn(Table.FromColumns({List.Distinct(Table[Subcategory])}),"Flag",(x)=>"SUB") & Table.AddColumn(Table.FromColumns({List.Distinct(Table[Category])}),"Flag",(x)=>"CAT"), "Index", 1, 1, Int64.Type)
(3)Then we can apply the data to Desktop and we can create a measure:
Measure = var _flag= MAX('X Table'[Flag])
var _name = MAX('X Table'[Column1])
var _sub = CALCULATE( SUM('Table'[Amount]) , TREATAS({_name} , 'Table'[Subcategory]))
var _cat = CALCULATE( SUM('Table'[Amount]) , TREATAS({_name} , 'Table'[Category]))
return
IF(_flag = "CAT",_cat ,_sub)
(4) Then we can put the fields on the visual and we can meet your need , the result is as follows:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @v-yueyunzh-msft ,
Thanks for the comment.
What I really need is to compare a subcategory to its category. If I take your example :
My Data:
We need to choose date and Subcatory, so we have 2 filters :
If i select 01/01/2023, this is the result :
we have 2 Subcategories ( and 2 categories). But when i selecte Subcategory S1, we shold to have this result without S10 :
The result of table is corect but not the report.
Thanks
Best Regards
Hi, @TotoBlank
Thanks for your response and detailed description for your question. I'm sorry i may make a mistake in this dax.
You can try to use dax to test:
Measure = var _flag= MAX('X Table'[Flag])
var _name = MAX('X Table'[Column1])
var _sub = CALCULATE( SUM('Table'[Amount]) ,KEEPFILTERS( TREATAS({_name} , 'Table'[Subcategory])))
var _cat = CALCULATE( SUM('Table'[Amount]) , TREATAS({_name} , 'Table'[Category]),ALL('Table'[Subcategory]) )
var _cat_table = VALUES('Table'[Category])
return IF(_flag = "CAT" && _name in _cat_table,_cat ,_sub)
Then we can meet your need:
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
hi @v-yueyunzh-msft ,
Thanks for your response. I'll try it tomorrow.
Do you know if is't possible to do this ? Compare periods: same month in 3 different years - Microsoft Power BI Community
Thanks
Best Regards,
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 |
---|---|
52 | |
27 | |
24 | |
14 | |
9 |
User | Count |
---|---|
75 | |
58 | |
47 | |
16 | |
12 |