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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Jyaul1122
Helper III
Helper III

Get RAG by Project but always keep one extra row for dedicated Project

I have two table Fact and Project Dim and related with Project column one to many.

DistrictProjectRAGGeo

ResortP11RedGeo1
ResortP22AmberGeo2
ResortP13GreenGeo1
ResortP21RedGeo2
ResortP31RedGeo3
DeltaP42AmberGeo4
DeltaP52AmberGeo5
DeltaP53GreenGeo5
DeltaDeltaBoundryGeo9
ResortResortBoundryGeo10

 

 

and Project DIM

DistrictProject

ResortP1
ResortP2
ResortP3
DeltaP4
DeltaP5
DeltaDelta
ResortResort

 

I have slicer , Project DIM and Geo.

 Whenever I select any slicer Project DIM and Geo , then I need to calculate rag that shows always rag of selected project + always RAG of of that Project (where Project = "Resort" or "Delta" based on District slicer)

Example: If i select Project P1 or Geo1 then output will be:

Jyaul1122_0-1767167992948.png

if I select P2 or Geo2 then:

Jyaul1122_1-1767168065516.png

if i select (P1 or Geo1) and (P2  or Geo2) then :

Jyaul1122_2-1767168150867.png

if I select (P4 or Geo4) then:

Jyaul1122_3-1767168301169.png

report:

Jyaul1122_4-1767168444557.png

 

I tried to write measure 

MAX('Fact'[rag]), that does not give proper RAG, how can i do using dax
1 ACCEPTED SOLUTION

Hi @Jyaul1122 ,

 

Just to understand the model a little bit better so that you can have the correct approach:

  • Geo column part of your Fact table?
  • Do you have any dimension on your model that has the Geo reference?

 

Asking this because of the context of your calculation lets just pick up a simple table with the following data:

 

Geo column
Geo1
Geo2
Geo3

 

 

If I use this column in a visualization and also use it in a slicer the visualization will only show the values I select.

 

Lets assume I have select Geo1 on the slicer the visual will only show visual Geo1 and since they are the same column I'm not able to show a different value because the overall data that I have available for the visual is only that specific values Geo1 all other no matter how I try to pick them up will never show because they are not part of the data selected for the visual.

 

When you use a dimension table you will be able to change the context of the fact table because you can overwrite the filter context being passed trough the relationship betwen dimension and fact using the ALL, CROSSFILTER or other similar formulas.

 

 


Regards

Miguel Fรฉlix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Portuguรชs





View solution in original post

7 REPLIES 7
v-saisrao-msft
Community Support
Community Support

Hi @Jyaul1122,

Have you had a chance to review the solution we shared by @MFelix? If the issue persists, feel free to reply so we can help further.

 

Thank you,

MFelix
Super User
Super User

Hi @Jyaul1122 ,

 

Try the following code:

RAG =
CALCULATE (
    VAR maximum_District =
        VALUES ( Dim[District] )
    VAR District =
        MAXX ( FILTER ( 'Fact', 'Fact'[Project] IN maximum_District ), 'Fact'[RAG] )
    VAR Project =
        MAXX (
            FILTER ( 'Fact', 'Fact'[Project] IN VALUES ( Dim[Project] ) ),
            'Fact'[RAG]
        )
    RETURN
        IF ( District = BLANK (), Project, District ),
    CROSSFILTER ( 'Fact'[Project], Dim[Project], NONE )
)

MFelix_0-1767193215799.png

 

MFelix_1-1767193226045.png

 

MFelix_2-1767193234625.png

 

My only question is concerning the GEO since when you refer geo 1 and p1 the resort is the value geo 10 do you want to overwrite that geo from the filter also?

 


Regards

Miguel Fรฉlix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Portuguรชs





@MFelix 

 

Its work fine, when we sliced upto Project Level but when we sliced upto Geo level the Resort is being filtered.

I would like to have Resort also there.

Result as per your measures:

Jyaul1122_0-1767245802551.png

requirements:

Jyaul1122_1-1767245885668.png

 

Hi @Jyaul1122 ,

 

Create a table for the Geo with unique values then try the following update of the measure:

RAG = 
CALCULATE (
    VAR maximum_District =
        VALUES ( Dim[District] )
    VAR maximum_geo =
        VALUES ( Geo[Geo] )
    
    VAR District =
        MAXX ( FILTER ( 'Fact', 'Fact'[Project] IN maximum_District  ), 'Fact'[RAG] )
    VAR Project =
        MAXX (
            FILTER ( 'Fact', 'Fact'[Project] IN VALUES ( Dim[Project] ) && 'Fact'[Geo] in maximum_geo ),
            'Fact'[RAG]
        )
    VAR Geo =
        MAXX ( FILTER ( 'Fact', 'Fact'[Project] IN maximum_District ), 'Fact'[RAG] )

    RETURN
       IF ( District = BLANK (), Project, District ), 
    
    
    CROSSFILTER ( 'Fact'[Project], Dim[Project], NONE )
)

 


Regards

Miguel Fรฉlix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Portuguรชs





@MFelix @v-saisrao-msft 

I can not create separate table for Geo as my data model is already overloaded.

Hi @Jyaul1122,

Have you had a chance to review the solution we shared by @MFelix? If the issue persists, feel free to reply so we can help further.

 

Thank you.

Hi @Jyaul1122 ,

 

Just to understand the model a little bit better so that you can have the correct approach:

  • Geo column part of your Fact table?
  • Do you have any dimension on your model that has the Geo reference?

 

Asking this because of the context of your calculation lets just pick up a simple table with the following data:

 

Geo column
Geo1
Geo2
Geo3

 

 

If I use this column in a visualization and also use it in a slicer the visualization will only show the values I select.

 

Lets assume I have select Geo1 on the slicer the visual will only show visual Geo1 and since they are the same column I'm not able to show a different value because the overall data that I have available for the visual is only that specific values Geo1 all other no matter how I try to pick them up will never show because they are not part of the data selected for the visual.

 

When you use a dimension table you will be able to change the context of the fact table because you can overwrite the filter context being passed trough the relationship betwen dimension and fact using the ALL, CROSSFILTER or other similar formulas.

 

 


Regards

Miguel Fรฉlix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Portuguรชs





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.