March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi
I am quite new in PBI, but in past I have made a few simple models. Now I have to use data from direct query (therefore I cannot use calculated columns anymore). Here is my problem:
Original solution using calculated columns
Type InvAmnt ccTotalPerType ccPercent
A 30 50 0.6 (30/50)
A 20 50 0.4 (20/50)
B 10 35 0.28 (10/35)
B 15 35 0.42 (15/35)
I think usage of calculated columns in this context is correct, but due to DirectQuery Model I cannot use it. Can I somehow calculate the ccPercent by using measures? I was thinking of creating a measure for each type, but I cannot predict all types that will appear in the data source. Below is the DAX formula used for calculated colum, but I cannot figure out how to derive Type for each row in case I will use a measure.
thank you for your advice
Solved! Go to Solution.
I think I found the function I was looking for:
SELECTEDVALUE(Soure[Type])
then I can migrate calculated column to measure and the measure will look like
thank you, but this solution will not work if I do not use Type in visuals.
I received a brilliant and simple solution from @smpa01
measure = DIVIDE(sum(tbl[invAmt]),calculate(sum(tbl[invAmt]),allexcept(tbl,tbl[Type])))
which perfectly works for me.
thank both of you
supicek
Hi @supicek
You'll need to use ALL() inside FILTER() to get all the rows in the table for that particular type
meTotalPerType =
CALCULATE(Sum([InvAmount]), FILTER(ALL('Source'),'Source'[Type]=SelectedValue('Source'[Type])))
Regards
Phil
Proud to be a Super User!
I think I found the function I was looking for:
SELECTEDVALUE(Soure[Type])
then I can migrate calculated column to measure and the measure will look like
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
82 | |
69 | |
53 | |
44 |
User | Count |
---|---|
202 | |
106 | |
100 | |
64 | |
56 |