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.
Hi All,
I have a single table where all sales records are kept.
there are 2 types of sales records in this table. Primary sales record have a [Main] attribute of "M", and sub-records have a [Main] attribute of "S". Primary Sales records can contain many sub-records.
unfortunately all these records are kept on a single table and the [cost] of primary records are missing.
I need to manually calculate the [cost] of primary records by suming up all sub-records. sub-records have the same [date],[user_id] and [type] as the primary record. (see exmaple below)
How can i write this measure as a new column
Solved! Go to Solution.
Hi @Bokchoy
Use this to create a new column
Col Cost = CALCULATE(SUM([Cost]), FILTER('Table', 'Table'[Date] = EARLIER('Table'[Date]) && 'Table'[user_id] = EARLIER('Table'[user_id]) && 'Table'[Type] = EARLIER('Table'[Type])))
Regards
Phil
Proud to be a Super User!
Hi @Bokchoy
Use this to create a new column
Col Cost = CALCULATE(SUM([Cost]), FILTER('Table', 'Table'[Date] = EARLIER('Table'[Date]) && 'Table'[user_id] = EARLIER('Table'[user_id]) && 'Table'[Type] = EARLIER('Table'[Type])))
Regards
Phil
Proud to be a Super User!
Thank you sir, works perfectly 🙂
Hi @Bokchoy
Use this measure
MCost = CALCULATE(SUMX('Table', [Cost]), FILTER(ALL('Table'), 'Table'[Date] = MAX('Table'[Date]) && 'Table'[user_id] = MAX('Table'[user_id]) && 'Table'[Type] = MAX('Table'[Type])))
regards
Phil
Proud to be a Super User!
Hi Philip,
This works perfect as a measure, but it doesnt seem to work as a custom column.
is there a way to achieve the same result while creating a new column?
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 |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |