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
Anonymous
Not applicable

select coulmns as per slicer value

Hi Team,

 

I have 2 tables in the backend: 

 

Country Compliant Full
US4
Ind11

 

Country YearCompliant Year
US20203
US20210
Ind20201
Ind20212

 

I have simple power bi report in which there are 2 slicers : Country and Year and in table visual i wanted to show 2 columns 

Country and Compliant

 

 when user filter only on Country then 2nd column should show value from Compliant full and when user chooses Country + Year or Just year then 2nd column should show value from Compliant Year. 

 

I used belwo DAX measure Compliant = IF(HASONEVALUE(Table2(Year), SUM(Compliant year), SUM(Compliant Full)) 

 

But it is giving me incorrect result in the Total of the table. 

 

Could you please help me on this ?

 

Thanks,

Shubham

 

 

 

1 ACCEPTED SOLUTION

@Anonymous , Problem That tell why we need calculate in SUMX

Measure = sumx(values(Country[country]), CALCULATE(IF(HASONEVALUE(Table2[Year]), SUM(Table2[Compliant year]), SUM(Table1[Compliant Full]))))

 

Please find the file after signature

 

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

It worked !! Thank you so much bhai !!

@Anonymous , Please accept the appropriate solution.

ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try this

Measure = if(ISFILTERED('Table (2)'[Year]),SUM('Table (2)'[Compliant Year]),sum('Table'[Compliant Full]))

1.PNG2.PNG

please see the attachment below

 





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

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , First on all create a common table country and use that in visual and have measure like

 

Country = distinct(Distinct(Table[Country]), distinct(Table2[country]))

https://youtu.be/Bkf35Roman8

 

sumx(Country, IF(HASONEVALUE(Table2(Year)), SUM(Table2[Compliant year]), SUM(Table1[Compliant Full])))

Anonymous
Not applicable

@amitchandak Yes..but the total is not working 

Capture.PNG

@Anonymous , Try this small change

 

sumx(values(Country[country]), IF(HASONEVALUE(Table2(Year)), SUM(Table2[Compliant year]), SUM(Table1[Compliant Full])))

Anonymous
Not applicable

No. Still it is giving same result. 

@Anonymous , Problem That tell why we need calculate in SUMX

Measure = sumx(values(Country[country]), CALCULATE(IF(HASONEVALUE(Table2[Year]), SUM(Table2[Compliant year]), SUM(Table1[Compliant Full]))))

 

Please find the file after signature

 

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.