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'd like to create virtual relationship between tables: 'Sales' and 'Plan', but TREATAS function doesn't work.
When any of the position from 'Plan' does not exist in 'Sales' it works incorrectly . Example:
Measure:
Plan =
CALCULATE (
SUM ( Plan[Value] ),
TREATAS (
SUMMARIZE ( 'Sales', 'Sales'[Year], 'Sales'[Month],'Sales'[Type],'Sale'[Region]),
plan[Year],plan[Month],plan[Type],plan[Region]))
Source:
https://i.ibb.co/M8Lfqpx/1.png
Power BI shows:
https://i.ibb.co/YXSGVZK/3.png
I expect:
https://i.ibb.co/NL4QqbT/3.png
Any Ideas?
Solved! Go to Solution.
Can you post some actual data per links below? I am not typing that in.
You cannot use TREATAS here. The function works by saying "TREAT this AS a filter for that." That is where TREATAS came from. If the data doesn't exist in this then it has nothing to filter for that. I'd be inclinced to merge or combine data in Power Query - would have to play with it. But need data.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingTo get what you want, you can't use columns from your fact tables. You ALWAYS have to use proper dimensions to slice data by. The hard rule is that data should never be sliced and diced by columns in fact tables. Only via dimensions. Stick to this and you'll be safe.
To get what you want, you can't use columns from your fact tables. You ALWAYS have to use proper dimensions to slice data by. The hard rule is that data should never be sliced and diced by columns in fact tables. Only via dimensions. Stick to this and you'll be safe.
Can you post some actual data per links below? I am not typing that in.
You cannot use TREATAS here. The function works by saying "TREAT this AS a filter for that." That is where TREATAS came from. If the data doesn't exist in this then it has nothing to filter for that. I'd be inclinced to merge or combine data in Power Query - would have to play with it. But need data.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reporting@Anonymous @edhans @wdx223_Daniel
I want to be able to display the plan for a all combinations, even if combination is not available in 'Sale'. How can I do it?
Sometimes we have a plan for a product but it hasn't been sold yet. Still, I would like the see plan: 800, not 700.
Dimension tables are created, but still the same problem.
@Anonymous the better way is to create dimension tables for date, region,type. then put them in the row
Combinations under TREATAS (the first argument) that do not exist in the target table to which you apply them (the other arguments) will, of course, not appear in the output. So, if there's a combination in Sales that does not exist in 'plan', it'll not show up. It just can't show up since TREATAS creates a set of rows that DO EXIST in the target table.
Here is your measure a bit more readable so I can understand what is going on:
Plan =
CALCULATE(
SUM( Plan[Value] ),
TREATAS(
SUMMARIZE(
'Sales',
'Sales'[Year],
'Sales'[Month],
'Sales'[Type],
'Sale'[Region]
),
plan[Year],
plan[Month],
plan[Type],
plan[Region]
)
)
The issue it seems is your Sales table doesn't have the 2020/2/2/B value to filter the plan table by, so it will not show up. There is nothing in sales to filter that.
if you need more help, please provide some data.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingCovering 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 |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
42 | |
33 | |
30 | |
18 | |
18 |