Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello everyone,
I am trying to get a KPI for BIAS which will allow me to count the number of rows at a summarized level which fall into a range.
The best idea I've had is to create a summarized table as a variable and then use it inside a calculate. Here I am trying to get the number of "green bars" which would be everything between -5% and 5%:
GreenBars =
VAR SumTable =
SUMMARIZECOLUMNS(
'Table'[Year],
'Table'[Period],
"BIAS", CALCULATE( [BIAS Base] )
)
Return
CALCULATE( COUNTROWS(SumTable),FILTER(SumTable, SumTable[BIAS] <= .05 && SumTable[BIAS] >= -.05))
*[BIAS Base] is a SUMX measure already calculated*
I need to do this against a summarized table because I have way more detail in the complete table but the information I am trying to show should be at the "Year Period" level.
So for example if I have the filters for this information I'd need for the KPI to be 2:
However, if I change my filters I'd need to get a different answer (3 in this case)
Is it possible to do this virtual table referencing inside measures?
Solved! Go to Solution.
Yes, I do it all the time, but your code would be:
GreenBars =
VAR SumTable =
SUMMARIZECOLUMNS(
'Table'[Year],
'Table'[Period],
"BIAS", CALCULATE( [BIAS Base] )
)
Return
COUNTROWS(FILTER(SumTable, [BIAS] <= .05 && [BIAS] >= -.05))
Hey @LABORSAL ,
the simple answer to your question is: yes.
It's very common to create a table (a virtual table) inside a measure, and assign this table to a variable.
And use this variable further down the measure.
For this, I'm wondering what is your exact question.
By, the way it's not necessary to wrap the reference to the measure [BIAS Base] into a CALCULATE, as referencing a measure implicitly is exactly doing this.
If your measure does not return the exact result, please provide a pbix file that contains sample data but still reflects your data model. Upload the file to onedrive or dropbox and share the link. If you are using Excel to create the sample data, share the Excel file as well.
Regards,
Tom
Yes, I do it all the time, but your code would be:
GreenBars =
VAR SumTable =
SUMMARIZECOLUMNS(
'Table'[Year],
'Table'[Period],
"BIAS", CALCULATE( [BIAS Base] )
)
Return
COUNTROWS(FILTER(SumTable, [BIAS] <= .05 && [BIAS] >= -.05))
That does, the trick, thanks!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 56 | |
| 47 | |
| 44 | |
| 20 | |
| 20 |
| User | Count |
|---|---|
| 73 | |
| 72 | |
| 34 | |
| 33 | |
| 31 |