Hi @Ritaf1983
Thanks for noticing! 😁 It's always great to see you around too.
Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I'm struggle to get this measure figured out.
I have data that includes a "# of reponses" for a month, and then a total score for a particular item. That looks like something like the below.
Now, in order for me to get the correct 3 month score, I need to multiple each months score by the reponse. Then take that total divided by the total of the reponses. And with some quick excel work, you can see the 3 month scores should be 71.1
I've been struggling with the Measure, and believe I need to use ISINSCOPE to correclty manipulate the total, but can't get this to work correctly yet.
Score =
VAR TotalScore = Sum(SampleScores[Org Score]) * CALCULATE(Sum(SampleScores[Org Score]), SampleScores[Description] = "# of responses")
RETURN
SWITCH(
TRUE(),
ISINSCOPE(SampleScores[Month]), Sum(SampleScores[Org Score]),
DIVIDE(
TotalScore,
Calculate(Sum(SampleScores[Org Score]), SampleScores[Description] = "# of responses")
)
)
Solved! Go to Solution.
Hi @ptmuldoon
The best practice for working with Power BI is to have separate columns for separate measures in the data table:
To achieve this you should pivot the columns in power query :
then you can create a date table + relationship with your "fact table"
Then create a 3 measures :
The pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Hi @ptmuldoon
As what @Ritaf1983 has mentioned, it is a best practice to have a separate column for each measure because If your table isn't the proper shape, you'll end up with a lengthy DAX 😊
Score =
VAR _responses =
CALCULATE (
SUM ( 'Table'[Org Score] ),
KEEPFILTERS ( 'Table'[Description] = "# of responses" )
)
VAR _intent =
CALCULATE (
SUM ( 'Table'[Org Score] ),
KEEPFILTERS ( 'Table'[Description] = "Intent to Recommend (Property)" )
)
VAR _total = _responses * _intent
VAR CellTotal =
SUM ( 'Table'[Org Score] )
VAR IntentTotal =
AVERAGEX ( VALUES ( 'Table'[Month] ), CALCULATE ( SUM ( 'Table'[Org Score] ) ) )
VAR GrandTotal =
SUMX (
ADDCOLUMNS (
SUMMARIZE ( 'Table', 'Table'[Month] ),
"@total",
CALCULATE (
SUM ( 'Table'[Org Score] ),
KEEPFILTERS ( 'Table'[Description] = "# of responses" )
)
* CALCULATE (
SUM ( 'Table'[Org Score] ),
KEEPFILTERS ( 'Table'[Description] = "Intent to Recommend (Property)" )
)
),
[@total]
)
VAR result =
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Table'[Description] ) = "Intent to Recommend (Property)", IntentTotal,
SELECTEDVALUE ( 'Table'[Description] ) = "# of responses", CellTotal,
GrandTotal
)
RETURN
result
Proud to be a Super User!
@danextian
Looks like we’re syncing thoughts in the forum lately 😊 It's Always great to see you around!🙃
Hi @Ritaf1983
Thanks for noticing! 😁 It's always great to see you around too.
Proud to be a Super User!
Hi @ptmuldoon
The best practice for working with Power BI is to have separate columns for separate measures in the data table:
To achieve this you should pivot the columns in power query :
then you can create a date table + relationship with your "fact table"
Then create a 3 measures :
The pbix is attached
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Thanks.
I ended up modifying the import to add some additional column to compute the 'raw score' there, and then simplified the measure. Not sure why I didn't think of that earlier.
And I'll be adding this into a larger dataset that already had the Date Table set up, etc.
Hi @ptmuldoon ,
Try this. Of course, replace any incorrect fields with your fields:
Score =
VAR _Description = SELECTEDVALUE(SampleScores[Description])
// Generate results, one for each description
VAR _SummarizeMe =
SUMMARIZE(SampleScores, [Month],
"@Responses", CALCULATE(SUM(SampleScores[Org Score]), KEEPFILTERS(SampleScores[Description] = "# OF RESPONSES")),
"@Scores", CALCULATE(SUM(SampleScores[Org Score]), KEEPFILTERS(SampleScores[Description] = "SCORES"))
)
RETURN
// check to see if current row context matches string
SWITCH( _Description,
"# OF RESPONSES", SUMX(_SummarizeMe, [@Responses]),
"SCORES", SUMX(_SummarizeMe, [@Scores]),
// if not, must be the row total line, let's multiple everything
SUMX(_SummarizeMe, [@Responses] * [@Scores])
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
76 | |
63 | |
51 | |
48 |
User | Count |
---|---|
204 | |
86 | |
64 | |
59 | |
56 |