Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Ghuiles
Advocate IV
Advocate IV

How to get in a virtual table more data than what ALLSELECTED is bringing?

Hello guys

 

With this measure i am trying to create a ranking by country.

The fact table has the value, the accounts, the entity (one country can have several entities), the date and the scenario (ACT, BUD etc).

In the results below "BUD" and "BY" are working.

"PY" is not working, because i did not managed to have the table pulling data from this year and last year (there is a filter set on the page to the current year).

If i take ALL, then there is way to much data (accounts etc).

I tried with ALLSELECTED as well, but no success 😞

Any hint on how i could solve this???

 

 

Ranking based on RANK 2h =
VAR _SelectedScenario =
SELECTEDVALUE ( 'Slicer Scenario'[ScenarioID] ) // NOT THE PARAMETER SCENARIO!!!
VAR _curCountry =
SELECTEDVALUE ( DimEntities[Country] ) // As SWITCH is expecting a scalar value, we need to have comprehensive statements below
// #1 Create the tables to perform the ranking upon
VAR _TableBUD =
SUMMARIZE (
ALLSELECTED ( 'Fact' ),
DimEntities[Country],
"Value1", [ACT Vs BUD]
)
VAR _TableBY =
SUMMARIZE (
ALLSELECTED ( 'Fact' ),
DimEntities[Country],
"Value2",
[Amount ACT]
- CALCULATE ( [Value_all], 'Fact'[Scenario] = "Budget" )
)
VAR _TableACT =
SUMMARIZE (
ALLSELECTED ( 'Fact' ),
DimEntities[Country],
"Value3", [Amount ACT]
)
VAR _TablePY =
SUMMARIZE (
ALL ( 'Fact' ),
DimEntities[Country],
"Value3", CALCULATE ( SUM ( 'Fact'[Value] ), 'Fact'[Scenario] = "Actual" )
) // #2 Create a column with the ranking on this virtual table
VAR _rankedTableBUD =
ADDCOLUMNS (
FILTER ( _TableBUD, [Country] <> BLANK () ),
"rankBUD", RANKX ( _TableBUD, [Value1],, DESC, SKIP )
)
VAR _rankedTableBY =
ADDCOLUMNS (
FILTER ( _TableBY, [Country] <> BLANK () ),
"rankBY", RANKX ( _TableBY, [Value2],, DESC, SKIP )
)
VAR _rankedTablePY =
ADDCOLUMNS (
FILTER ( _TablePY, [Country] <> BLANK () ),
"rankPY", RANKX ( _TablePY, [Value3],, DESC, SKIP )
)
RETURN
SWITCH (
_SelectedScenario,
"BUD", MAXX ( FILTER ( _rankedTableBUD, [Country] = _curCountry ), [rankBUD] ),
"BY", MAXX ( FILTER ( _rankedTableBY, [Country] = _curCountry ), [rankBY] ),
"PY", MAXX ( FILTER ( _rankedTablePY, [Country] = _curCountry ), [rankPY] )
)

 

Thanks in advance

G.

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.