Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I have two tables:
SALES
id | product | cart_id | week |
1 | A | 90 | 25 |
2 | B | 90 | 25 |
3 | C | 91 | 27 |
4 | A | 91 | 27 |
5 | A | 91 | 27 |
SEPCIAL_SALES
id | product | cart_id | week |
17 | A | 234 | 25 |
18 | B | 234 | 25 |
18 | C | 235 | 25 |
19 | A | 236 | 27 |
20 | C | 236 | 27 |
Now I want to divide the distinct count of the card_id like:
COUNT(DISTINCT(SALES[card_id])) / COUNT(DISTINCT(SEPCIAL_SALES[card_id]))
And the results should be plotted per week.
In this case:
25 | 1/2 |
27 | 1/1 |
How do I do that?
Solved! Go to Solution.
Hi, @Anonymous
Create a bridge table using the week field, and establish a one-to-many relationship with the other two tables
then try to create measures like below:
_CountOfSales =
CALCULATE (
DISTINCTCOUNT ( 'SALES'[cart_id] ),
FILTER ( ALL ( 'SALES' ), [week] = MAX ( 'bridgeTable'[Week] ) )
)
_CountOfSepcialSales =
CALCULATE (
DISTINCTCOUNT ( SEPCIAL_SALES[cart_id] ),
FILTER ( ALL ( 'SALES' ), [week] = MAX ( 'bridgeTable'[Week] ) )
)
_Result =
FORMAT ( 'Mea'[_CountOfSales], "General Number" ) & "/"
& FORMAT ( 'Mea'[_CountOfSepcialSales], "General Number" )
Sample:
result:
Please refer to the attachment below for details
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
Create a bridge table using the week field, and establish a one-to-many relationship with the other two tables
then try to create measures like below:
_CountOfSales =
CALCULATE (
DISTINCTCOUNT ( 'SALES'[cart_id] ),
FILTER ( ALL ( 'SALES' ), [week] = MAX ( 'bridgeTable'[Week] ) )
)
_CountOfSepcialSales =
CALCULATE (
DISTINCTCOUNT ( SEPCIAL_SALES[cart_id] ),
FILTER ( ALL ( 'SALES' ), [week] = MAX ( 'bridgeTable'[Week] ) )
)
_Result =
FORMAT ( 'Mea'[_CountOfSales], "General Number" ) & "/"
& FORMAT ( 'Mea'[_CountOfSepcialSales], "General Number" )
Sample:
result:
Please refer to the attachment below for details
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , You need to create common tables like a week, product, and card id and analyze data with these common dimensions
Bridge Table: https://www.youtube.com/watch?v=Bkf35Roman8&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=19
You need to be in star schema
https://www.sqlbi.com/articles/the-importance-of-star-schemas-in-power-bi/
This is not helpful.
The solution was to build a quickmeasure in the plot.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
135 | |
117 | |
101 | |
71 | |
61 |