Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello,
I have 2 months of data. I try to filter sales by type of client. The problem is type of client type can be different each month as per below table (example) relation many to many.
When I try to visualize this data in the table I get incorrect values e.x. For Oct 2022, Type of Client = 1 I get value of 600 because Client 2 has Client Type = 1 in Nov 2022.
I would like to create a measure that consider 'type of client' for value month.
any tips are welcomed.
Thank you in advance.
Inteq
Solved! Go to Solution.
I would highly recommend to rewrite your model to this:
Your current model with many-to-many connections and bi-directional filtering will make it quite hard to construct even the simplest measures(which obviously is the reason you have posted your question).
To modify your model, open Transform Data/Power Query, and merge Sales with ClientType on ClientName and Date. This will add client type to your sales table. As the the ClientType-table does not contain any other interesting information, it is not strictly neccessary to keep it, but it does not harm either.
Now you can get your desired output like this:
I would highly recommend to rewrite your model to this:
Your current model with many-to-many connections and bi-directional filtering will make it quite hard to construct even the simplest measures(which obviously is the reason you have posted your question).
To modify your model, open Transform Data/Power Query, and merge Sales with ClientType on ClientName and Date. This will add client type to your sales table. As the the ClientType-table does not contain any other interesting information, it is not strictly neccessary to keep it, but it does not harm either.
Now you can get your desired output like this:
Hi, @Inteq,
could you provide a table displaying the desired outcome? And could you also provide a screen shot of your data model?
Assuming you have no relationship between you tables, you can use this measure:
Measure1 =
VAR _clientType =
CALCULATE ( SELECTEDVALUE ( ClientType[Type of client] ) )
VAR _clientsFromType =
CALCULATETABLE (
VALUES ( ClientType[ClientName] ),
FILTER ( ClientType, ClientType[Type of client] = _clientType )
)
VAR _month =
CALCULATE ( SELECTEDVALUE ( ClientType[Date] ) )
RETURN
SUMX (
CALCULATETABLE (
ClientValue,
FILTER (
ClientValue,
CONTAINS ( _clientsFromType, ClientType[ClientName], ClientValue[ClientName] )
&& ClientValue[Date] = _month
)
),
ClientValue[ValueCol]
)
but this is rather complex for such a simple task, you would be able to write a much simpler statement if your model your data properly
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
87 | |
87 | |
81 | |
63 | |
49 |
User | Count |
---|---|
121 | |
109 | |
81 | |
67 | |
67 |