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

Don'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.

Reply
JessA
Frequent Visitor

Calculation Groups - Problems when using selectedmeasure twice in a calculation item

Hi Everyone,

 

I've been exploring Calculation groups recently and love how they've let me clean up my measures. I've just run across a strange issue with only one of the calculation items in my calculation group. The calculation Item is called 'KPI Pass %' and conditional formatting is not working on it even though it is working on two other calc items ('Created' and 'KPI Pass' respectively). Here is an example, the cells in each row should be the same colour:

JessA_0-1713482157626.png

As you can see the conditional formatting is applied to Created and KPI Pass but not to KPI Pass %.

 

I also get an error when I try to filter other visuals by selecting a value in the KPI Pass % column. The error is Cannot convert [title of matrix from a measure] of type text to type numeric. I am not sure why its trying to convert the title measure of the other matrix to Numeric. I don't get this error if I select a value in the Created or KPI Pass columns. 

 

JessA_1-1713482185628.png

JessA_2-1713482384960.png

 

KPI Pass % calculation item is based on the other two, DAX:

 

KPI Pass % =
DIVIDE (
    CALCULATE ( SELECTEDMEASURE (), DateTypes[Date Types] = "KPI Pass" ),
    CALCULATE ( SELECTEDMEASURE (), DateTypes[Date Types] = "Created" )
)

 

 

I think the problem might be that I use SELECTEDMEASURE twice in the one calculation item. 

 

Has anyone else come across this issue or have an suggestions to fix it? 

 

Thank you.

3 REPLIES 3
JessA
Frequent Visitor

Thanks @amitchandak, I have a measure to assess the current priority and the condiitonal formatting is based on that. For Priority 1, the cell fill shoule be red, for priority 2-4 it should be yellow and then for priority 5-7 it should be green. So the conditional formatting is working for the calculation items 'Created' and 'KPI Pass', but not for the 'KPI Pass %'. 

 

JessA_0-1713729433162.png

 

The only difference I can see between the calc items is that the one the conditional formatting is not working for references SELECTEDMEASURE twice. The calculation itself is working correctly, just not the conditional formatting.

BLeZLiE
Frequent Visitor

Just to follow on from @amitchandak's point around calculation groups and conditional formatting. There are some good sources online about how to use calculation groups with condtional formatting. I've added a link from well renowed Alberto Ferrari from SQL BI discussing a method which involves field parameters.

amitchandak
Super User
Super User

@JessA , I created a calculation group

Divide1 = divide(CALCULATE(SELECTEDMEASURE(), 'Item'[Brand] = "Brand 1"), CALCULATE(SELECTEDMEASURE(), 'Item'[Brand] = "Brand 2"))

 

and that is working

amitchandak_0-1713494101542.png

 

For conditional formatting, you should consider measure-based conditional formatting

 

Please let me know what is exactly you wanted to achieve

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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